namespace ChemicalTest
{
enum Echemicals { oxygen, hydrogen, carbon }
public class Chemicals
{
int[] chemicals = new int[3];
public Chemicals()
{
foreach (int i in chemicals)
{
int[i] = //How can I reference each enumeration here?
//For example (pseudocode) - (i)Echemicals
}
}
}
}
I have three enum values: oxygen {0}, hydrogen{1}, carbon{2}
I'd like to put each of these enums into an array to later be referenced by their own number, so that I could call them from the array.
I can use (int)Echemicals.hydrogen to return the default value of the second enumeration {1} but I don't know how to do this in reverse.
I am trying to store each of the names of the chemicals in an array by calling them by their integer value.