Get member name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • #Hai

    #1

    Get member name

    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


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Get member name

    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).G etProperties(Bi ndingFlags.GetP roperty | BindingFlags.Pu blic |
    BindingFlags.St atic);

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

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    " #Hai" <ReplyToGroup@M ail.com> wrote in message
    news:egiD1qjRDH A.3236@TK2MSFTN GP10.phx.gbl...[color=blue]
    > 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),[/color]
    how[color=blue]
    > to that ?
    > Thanks
    >
    >[/color]


    Comment

    Working...