我有一个这样的字符串数组:
namespace DynamicCore
{
public class DynamicCode
{
public string ProcessName { get; set; }
public DynamicCode()
{
List<Variable> variableList = new List<Variable>();
Variable Variable = new Variable();
Variable.ID = "Variable_26545789";
Variable.Name = "var1";
variableList_Process_1.Add(Variable);
Variable = new Variable();
Variable.ID = "Variable_vdvd3679";
Variable.Name = "var2";
variableList_Process_1.Add(Variable);
}
}
}
我使用CompileAssemblyFromSource
这样编译它(GetCode
获得字符串数组)并将类存储在Memory:
CompilerResults results = provider.CompileAssemblyFromSource(parameters, GetCode());
我需要得到variableList
并在列表框中显示Variable.Name
项。我测试了GetFields
和GetProperty
,但没有一个不能正常工作。
我需要得到变量列表和显示变量。在列表框中命名项目。我测试了GetFields和GetProperty,但没有一个不能正常工作。
variableList
和Variable
都是本地变量。它们不在DynamicCode()
构造函数的作用域之外。
将它们声明为DynamicCode
类中的字段或属性