C# compiler compiles .txt .obj .java files

c#, compiler-construction

Solution

Beginning C# Objects: From Concepts to Code - By Jacquie Barker, Grant Palmer

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

Also from the same book.

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.

Problem

``` using System; class Program { public static void Main() { Console.WriteLine("Hello World!"); Console.ReadLine(); } } ``` 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` Surprisingly, it compiles all the 3 files into an executable and executes it successfully. Could anyone give me an explanation on this behavior?

Original source