Get member name

  • Thread starter Thread starter #Hai
  • Start date Start date
H

#Hai

Hi,
We have a long list of color name: Color.Red, Color.Green, Color.Green....
If I want to get the list of all color name (certainly by programming), how
to that ?
Thanks
 
Hai,

If you want to get all the color names, then you would want to get all
of the static properties on the color structure. You can use reflection to
do this:

// Get the property info instances for all static properties on the Color
structure.
PropertyInfo[] pobjInfos =
typeof(Color).GetProperties(BindingFlags.GetProperty | BindingFlags.Public |
BindingFlags.Static);

Then, you can cycle through the property infos and get the names of the
properties.

Hope this helps.
 

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

Similar Threads


Back
Top