[英]Get nested delegate type ref. from inside a generic class
我尝试使用以下方法从DomainDB类检索“ PreProcess”的类型
Type.GetType("DomainDBManager.DomainDB`1[System.String]+PreProcess")
但这返回null。 无论如何,有使用Type.GetType获取公共字段“ PreProcess”吗?
命名空间DomainDBManager {公共类DomainDB <T> {public Action <string>预处理; }}
您目前正试图通过名字来获得一个类型 - PreProcess
是的领域 DomainDB<T>
类型,所以Type.GetType
是行不通的。 您需要先获取类型,然后从中获取字段:
Type type = Type.GetType("DomainDBManager.DomainDB`1[System.String]");
FieldInfo field = type.GetField("PreProcess");
Type fieldType = field.FieldType;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.