我怎样才能得到一个(泛型函数中的类型)的 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