How to compile just one file in c#?

前端 未结 7 1292
星月不相逢
星月不相逢 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:37

    Yes it's possible. You can call the compiler directly using command prompt. i.e.

    1. Create single file 'hello.cs'
    2. Open the Visual Studio command prompt
    3. Navigate to the directory that has 'hello.cs'
    4. Run csc hello.cs
    5. Execute your single file by typing hello.exe

    This will at least tell you whether a single file compiles or not. You can find more information here: https://msdn.microsoft.com/en-us/library/78f4aasd.aspx

提交回复
热议问题