Given the following definitions:
public enum SampleEnum1 { Uno, Dos, Tres }
public enum SampleEnum2 { One, Two, Three, Four }
I need two methods doing this:
- Given the integer 2, return
Dos
if applied toSampleEnum1
,Two
if applied toSampleEnum2
- Given the value
One
, return1
In fact I need to translate an enumeration litteral into its sequence number in the enumeration definition, and vicae versa.
I don't mind using generics, reflexion, or whatever, as long as the same 2 methods work for any enumeration.
Do you have the solution?