How to get the fully qulified type of an Enum?

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
 
H

Herfried K. Wagner [MVP]

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()'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top