/*
Author: Jiangong SUN
*/
CSharp compiler is invoked at the command line using csc.exe file located <C:\Windows\Microsoft.NET\Framework\v2.0.50727>.
CSharp Compiler compiles CSharp code to MSIL(Intermediate Language) at compilation time in CLR (Common Language Runtime). The compiled code(exe or dll) is managed code, and is managed by Garbage Collector(GC).
When you execute the exe or dll file, it will be compiled by JIT(Just-In-Time) compiler, and generate native machine code for specific CPU.
When you want to compile a class using csc.exe you may encounter this error:CS 1619: Cannot create temporary file
All you need to do is run cmd.exe as "Administrator". Re-run the compiler and it will compile the csharp file to an executable(.exe).
Compile csharp code to DLL (dynamic link library).
Note: .exe and .dll are all assembly files.
Compile CSharp code to named executable file.
Compile all the .CS files in current directory with a name of executable, the code mode can be DEBUG or RELEASE with optimization.
It will generate code in mode "DEBUG" like:
#if DEBUG
LazySingleton s2 = LazySingleton.Instance;
int num2 = s2.MultiplyBy5(20);
Console.WriteLine(num2);
#endif
Compile all the .CS files in current directory to a named DLL file "/target:library /out:LazyDLL.dll", and generate debug file(.pdb) with option "/debug", and doesn't display Microsoft copyright with option "/nologo", with warning level (0-4) "/warn:0".
Compile all the .CS file in current directory to a user personalized type of DLL.
Compile a class inside a .CS file who reference another class in another .CS file.
For example:
To compile <ConsoleApplication.cs>, you need to reference <ConsoleClass.cs> before it.
I hope this post can do help in your work. Enjoy coding!