First, you have to cast your input string into an enum of your choice. That can be done with Enum.Parse(Type, String)
:
Planets planet = Enum.Parse(typeof(Planets), "Mercury")
Then you need to get the numerical value from the enum, which is a simple cast to integer:
int value = (int)planet;
Be careful with the first step: if the user inputs a string that is not valid, you'll get an exception which you'll have to handle. To avoid that you can use the Enum.TryParse()
method which return a bool indicating the success of the action and pass the resulting enum as an out parameter.
Planets result;
bool success = Enum.TryParse<Planets>("Mars", true, out result);
if(success){
Console.Write((int)result);
} else {
Console.Write("no match");
}