我收到一个未处理的类型异常
UgenityAdministrationConsole.exe 中发生“System.NullReferenceException”
附加信息:对象引用未设置为对象的实例。
这发生在我的类构造函数中。
这是我的代码:
public static object dummyObject = new object(); // create a dummy object to use for initializing various things
public class EntityValuesClass
{
public List<EntityValue> EntityValues { get; set; }
public EntityValuesClass(EntityType _entType)
{
Type t;
PropertyInfo[] propInfoArray;
EntityValue entValue = new EntityValue();
t = entityTypeToType[_entType];
propInfoArray = t.GetProperties();
foreach (PropertyInfo propItem in propInfoArray)
{
entValue.FieldName = propItem.Name;
entValue.FieldValue = dummyObject;
EntityValues.Add(entValue); <------ this is where the error is happening
}
}
}
public class EntityValue
{
public string FieldName { get; set; }
public object FieldValue { get; set; }
}