How to get the fully qulified type of an Enum?

  • Thread starter Thread starter KK
  • Start date Start date
K

KK

Hi

I have a method that checks the qualified type names

public method( object instance);

In the method I check the type and do the
necessary procesing. I use
<object>.GetType().ToString() which
gives me the types such as;

System.Windows.Forms.MenuItem
System.Windows.Forms.ToolBarButton

etc...

However, Sometimes I am passing Enums
(Value Type). For example when I pass
System.Windows.Forms.Keys.F1,

the instance I get is just "F1" I want to get
the fully qulified "Windows.Forms.Keys"
which will tell me that the F1 is an enum value
of "Windows.Forms.Keys"

rgds
KK
 
KK said:
I have a method that checks the qualified type names

public method( object instance);

In the method I check the type and do the
necessary procesing. I use
<object>.GetType().ToString() which
gives me the types such as;

System.Windows.Forms.MenuItem
System.Windows.Forms.ToolBarButton

etc...

However, Sometimes I am passing Enums
(Value Type). For example when I pass
System.Windows.Forms.Keys.F1,

the instance I get is just "F1" I want to get
the fully qulified "Windows.Forms.Keys"
which will tell me that the F1 is an enum value
of "Windows.Forms.Keys"

Use 'GetType().FullName' instead of 'GetType().ToString()'.
 
Back
Top