【发布时间】:2010-07-13 13:01:07
【问题描述】:
我尝试使用
从 DomainDB 类中检索“预处理”的类型Type.GetType("DomainDBManager.DomainDB`1[System.String]+PreProcess")
但这会返回 null。有没有使用 Type.GetType 获取公共字段“PreProcess”?
命名空间域数据库管理器
{
公共类 DomainDB
【问题讨论】:
我尝试使用
从 DomainDB 类中检索“预处理”的类型Type.GetType("DomainDBManager.DomainDB`1[System.String]+PreProcess")
但这会返回 null。有没有使用 Type.GetType 获取公共字段“PreProcess”?
命名空间域数据库管理器
{
公共类 DomainDB
【问题讨论】:
您当前正在尝试按名称获取 type - PreProcess 是 DomainDB<T> 类型的 字段,因此 Type.GetType 不会去工作。您需要先获取类型,然后从中获取字段:
Type type = Type.GetType("DomainDBManager.DomainDB`1[System.String]");
FieldInfo field = type.GetField("PreProcess");
Type fieldType = field.FieldType;
【讨论】: