I have the following code:
// Obtain the string names of all the elements within myEnum String[] names = Enum.GetNames( typeof( myEnum ) ); // Obtain the values of all the elements within myEnum Array values = Enum.GetValues( typeof( myEnum ) ); // Print the names and values to file for ( int i = 0; i < names.Length; i++ ) { print( names[i], values[i] ); }
However, I cannot index values. Is there an easier way to do this?
Or have I missed something entirely!
Or, you can cast the System.Array that is returned:
But, can you be sure that GetValues returns the values in the same order as GetNames returns the names ?