How to compile just one file in c#?

Viewed 13564

In VC++ I can press CTRL+F7 to compile a single file, or right click on a source file ot compile it. Is it possible to compile a single file (or current file) in C#?

I would like to for example know if my current file has any errors in it without having to compile everything.

7 Answers

Yes, this can be done using the Mono .NET Framework. At the command prompt, run mcs path/to/file.cs.

From the Mono docs:

To compile, use csc:

csc hello.cs

Note: csc compiler is not available on all platforms or in very old Mono versions, in such cases use mcs instead.

The compiler will create “hello.exe”, which you can run using:

mono hello.exe
Related