如题

解决方案 »

  1.   

    匿名类
    CSharpCodeProvider p = new CSharpCodeProvider();
      CompilerParameters param = new CompilerParameters(new string[] { "System.dll" });
      string s = "namespace __ns{public class AAA{ public string name{get{return '";}} }}";
      CompilerResults rel = p.CompileAssemblyFromSource(param, s);
      Type t = rel.CompiledAssembly.GetType("");
      object o = t.GetConstructor(System.Type.EmptyTypes).Invoke(null);
      MessageBox.Show(t.GetProperty("name").GetValue(o, null).ToString());