C#编译器编译.txt .obj .java文件 [英] C# compiler compiles .txt .obj .java files

查看:83
本文介绍了C#编译器编译.txt .obj .java文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
class Program {
    public static void Main() {
        Console.WriteLine("Hello World!");
        Console.ReadLine();
    }
}

我将文件另存为 1.java 2.obj 3.txt
然后我使用Visual Studio命令提示符来编译文件: csc 1.java csc 2.obj csc 3.txt

I save the file as 1.java, 2.obj and 3.txt. I then use the Visual Studio Command Prompt to compile the file: csc 1.java csc 2.obj csc 3.txt

令人惊讶的是,它将所有3个文件编译为可执行文件并成功执行。

Surprisingly, it compiles all the 3 files into an executable and executes it successfully.

有人可以给我对此行为的解释吗?

Could anyone give me an explanation on this behavior?

推荐答案

开始的C#对象:从概念到代码-Jacquie Ba rker,格兰特·帕尔默(Grant Palmer)


建议的约定是使用
扩展名.cs结束源代码文件名,但是没有必要这样做;可以想象,源文件
可以命名为Person.boo,例如

The recommended convention is to end source code file names with the extension .cs, but there is no requirement to do so; a source file could conceivably be named Person.boo, for example

也可以从同一本书


类似地,C#源文件的名称不必与内部定义的类或接口的名称
匹配。该文件。例如,可以将定义Professor类的
代码放在名为
Blah.cs的文件中,但是将源文件名匹配为
的源文件名与该类的名称或在文件内声明的接口。

Similarly, the name of a C# source file doesn't have to match the name of the class or interface defined within that file. For example, the code defining the Professor class could be placed in a file named Blah.cs, but it's considered good practice for a source file name to match the name of the class or interface declared within the file.

这篇关于C#编译器编译.txt .obj .java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆