[英]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.