Get Enum Index Value??
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Get Enum Index Value??

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Location
    (Presently) Bahrah S.A.
    Posts
    24

    Get Enum Index Value??

    Is it Possible to get the "Index Value" or position from an Enum?

    There are no apparent properties of a defined ENUM only the individual elements. I know I can assign my Enum Values to an Array (one by one) and index through Them, but I was hoping to be able to directly access the elements of the Enum by index.

    Optionally is there a nice clean way to assign the Enum to an Array?

    Regardless of the Array Style (Dynamic / Static) ,Variable Type, or initialization state I can't seem to be able to assign the values without Looping Through each element. I've tried assigning the array to the Enum definition and a defined variable of the enum. Nothing works, which then of course makes me question the value of the Enum over individual constant declarations, aside from the Intellisense popups. So I come back to the conclusion that I'm missing something in regards to Enum usage. Any insight would be appreciated.

  2. #2
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    149

    Re: Get Enum Index Value??

    If you are creating Collection of your own class Then you can include addtional element as key in your class and use that property as key for add function in your collection. Make sure you are not sending duplicate value to this property. you can use this key for accessing elements of collection. Note: Key should be String type.
    If you understand how this works you can modify remove method of collection to handle duplicate values also
    Encourage the efforts of fellow members by rating

    Lets not Spoon Feed and create pool of lazy programmers

    - ComIT Solutions

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center