DotNET > Enumerations > What would be the output of following code snippet?
What would be the output of following code snippet?
Value of color variable is "Red".
Enum.Parse will convert the string variable color to enum MyColorEnum, resulting in MyColorEnum.Red.
Enum.Parse accepts two parameters. First one is type of enum and next is string value.
There is another variant of Enum.Parse which accepts a third parameter, boolean type ignoreCase, which will ignore the case of the string input.
.NET CLR will throw a run time error "Requested value 'red' was not found."
However with below code, the output will be "Red", because we ignored the case of the string with the help of third parameter.
1. What would be the output of following code snippet?
2. Which method should be use, while converting string values to enum?
3. Which of the following CANNOT be used as an underlying datatype for an enum in C#.NET?