开发者

How to get the full type name?

开发者 https://www.devze.com 2023-02-05 11:23 出处:网络
have a class, can I 开发者_运维知识库get the full type name in the form like A,B?Use AssemblyQualifiedName on the Type instance:

have a class, can I 开发者_运维知识库get the full type name in the form like A,B?


Use AssemblyQualifiedName on the Type instance:

typeof(string).AssemblyQualifiedName

Or:

typeof(YourClass).AssemblyQualifiedName

Also, if you have an instance of an object, and want to know the full type name from that; use GetType() to get the Type instance from the instance.


You can also use Type.FullName in case you're not interested in the assembly properties

Following your example:

typeof(A).FullName;

or from an instance of A:

anA.GetType().FullName;
0

精彩评论

暂无评论...
验证码 换一张
取 消