Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the full type name?

Tags:

c#

.net

have a class, can I get the full type name in the form like A,B?

like image 461
user496949 Avatar asked Jan 20 '11 08:01

user496949


2 Answers

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.

like image 137
driis Avatar answered Sep 25 '22 09:09

driis


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;
like image 35
vc 74 Avatar answered Sep 22 '22 09:09

vc 74