How to compile just one file in c#?

前端 未结 7 1187
星月不相逢
星月不相逢 2020-12-28 15:54

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#?

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-28 16:33

    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
    

提交回复
热议问题