How to: class / type name

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Is there an easy way to get a string representation? Wasn't apparent to me
from looking at the reflection class.

Thanks,
Eric
 
Eric said:
Is there an easy way to get a string representation? Wasn't apparent to me
from looking at the reflection class.

Of a type's name? The Type.Name property or Type.FullName is probably
what you want.

You get a runtime Type instance from typeof(ClassName) or
ClassInstance.GetType().
 
Hi Eric,

Type type = typeof(System.Object); // Type known at design-time

string name = type.FullName;
// System.Object

string qualified = type.AssemblyQualifiedName;
// System.Object, mscorlib, Version=2.0.0.0, Culture=neutral,
// PublicKeyToken=b77a5c561934e089

or

// Type unknown at design-time
Type type = objAnyInstance.GetType();
 
Back
Top