CSharpCompiler 是免费开源的 C# 编译器,可编译 C# 源代码。
示例
CSharpCompiler compiler = new CSharpCompiler (); compiler.SourceCode = richTextBox1.Text; compiler.Output = CSharpCompiler.OutputType.EXE; compiler.Path = "C:\\Users\\Danny\\Desktop"; compiler.NameOfAssembly = "Hello World!"; compiler.CompileCode();if (compiler.SuccessfullCompilation == false ) { if (compiler.CompilerErrors != null ) listBox1.Items.AddRange(compiler.CompilerErrors); if (compiler.CompilerWarnings != null ) listBox1.Items.AddRange(compiler.CompilerWarnings); }