Say that I have variable whose value (for example, "listMovie"
) is the name of an enum
member:
public enum Movies
{
regMovie = 1,
listMovie = 2 // member whose value I want
}
In this example, I would like to get the value 2
. Is this possible? Here is what I tried:
public static void getMoviedata(string KeyVal)
{
if (Enum.IsDefined(typeof(TestAppAreana.MovieList.Movies), KeyVal))
{
//Can print the name but not value
((TestAppAreana.MovieList.Movies)2).ToString(); //list
Enum.GetName(typeof(TestAppAreana.MovieList.Movies), 2);
}
}