public static void Test1()
{
CodeDomProvider compiler = new CSharpCodeProvider(); //编译器
CompilerParameters comPara = new CompilerParameters(); //编译器参数
comPara.GenerateExecutable = true; // 生成exe文件
comPara.GenerateInMemory = false; // 是否在内存在输出
comPara.OutputAssembly = "SimpleCompile.exe"; // 输出文件
compiler.CompileAssemblyFromSource(comPara, GetCode1());
// 在当前目录生成 SimpleCompile.exe ,可直接运行
}
public static string GetCode1()
{
string code = @"using System;
class Test
{
static void Main()
{
int i = 1;
Console.WriteLine("$@"{i} Hello world""); //这里会动态编译报错,不识别的符号$
Console.ReadLine();
}
}";
return code;
}
请问要怎么让编译器识别内插这种语法