To answer your question "how can I get the integer for string value":
To convert from a string into an enum, and then convert the resulting enum to an int, you can do this:
public enum Animals
{
dog = 0,
cat = 1,
rat = 2
}
...
Animals answer;
if (Enum.TryParse("CAT", true, out answer))
{
int value = (int) answer;
Console.WriteLine(value);
}
By the way, normal enum naming convention dictates that you should not pluralize your enum name unless it represents flag values (powers of two) where multiple bits can be set - so you should call it Animal
, not Animals
.