簡體   English   中英

來自的System.Type <T>

[英]System.Type from <T>

我如何獲得(通用函數中的Type)的System.Type? 我需要獲取類名稱的字符串表示形式。

typeof(T).GetType().Name

給我'runtimetype',我不想。

做就是了:

typeof(T)

這將導致T的實際類型,對於您的通用類/方法的特定實例,無論T是什么。 如果T碰巧是System.String ,則將獲得表示System.String的類型的實例。

你可以這樣使用嗎?

Type thisType = this.GetType();   // Get your current class type
thisType.FullName                 // Get your Assembly Name.

在您的課程中編輯

Type thistype = TypeOf(T);
thisType.Name                    // Get you class name 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM