July 10th, 2009, 04:22 AM
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.
July 11th, 2009, 06:21 AM
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
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!