Iterate through a list of Enums or otherwise use a Variable to represent them

I’ve been running into this issue for a while now, I need a way to use an enum name as a variable e.g.,
(I think I got that right, I’ve been up all night)

public class Example : MonoBehaviour 
{
 while (i < 100)
 {
     newValue = enumValues.i;
     i += 25;
 }
}

public enum enumValues : int
    {
        25 = 5000,
        50 = 250000,
        75 = 2,
    }

Of course that can’t be done but…

  1. Is there anyway to pull off this type of iteration without using cases?
  2. Is there a way to not hardcode an Enum into place? e.g.,
    (and I’m assuming the following doesn’t work but I haven’t tried it lately)
public class Example : MonoBehaviour 
{
desiredString = "derp";
newValue = enumValues.desiredString;
}

public enum enumValues : int
    {
        derp = 5000,
        hurp = 250000,
        baderp = 2,
    }

Yes, you can use the System.Enum class to get a list of all the possible values to iterate through (the GetValues() function):
http://msdn.microsoft.com/en-us/library/system.enum.aspx

No. It appears that you are looking for a dynamic structure that maps names to numbers. For that, you could use the Dictionary<,> class (or the Hashtable class if you can’t use Generics):
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
http://msdn.microsoft.com/en-us/library/system.collections.hashtable.aspx

Thanks.

You could use reflection, but that would be using the proverbial sledgehammer.

If by “not hardcode an Enum into place” you mean “can I convert a string into the corresponding Enum value?” then yes, you can, using Enum.Parse.