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.
 
Back
Top