check out System.Enum.Parse:
enum Colors {Red, Green, Blue}
// your code:
Colors color = (Colors)System.Enum.Parse(typeof(Colors), "Green");
More Related Contents:
- What is the difference between String and string in C#?
- Can I convert a C# string value to an escaped string literal?
- What is the difference between String and string in C#?
- Get string between two strings in a string
- String output: format or concat in C#?
- Differences in string compare methods in C#
- How can I split a string with a string delimiter? [duplicate]
- How do I write a backslash (\) in a string?
- Comparing two strings, ignoring case in C# [duplicate]
- How to replace multiple white spaces with one white space
- Evaluate string with math operators [duplicate]
- Splitting a string / number every Nth Character / Number?
- Convert JSON String to JSON Object c#
- Is String.Contains() faster than String.IndexOf()?
- Is there an alternative to string.Replace that is case-insensitive?
- Can I “multiply” a string (in C#)?
- Java equivalents of C# String.Format() and String.Join()
- How to replace part of string by position?
- Is String a primitive type?
- How to return text from Native (C++) code
- How to split a number into individual digits in c#? [duplicate]
- If strings are immutable in .NET, then why does Substring take O(n) time?
- string.ToLower() and string.ToLowerInvariant()
- How do I get the last four characters from a string in C#?
- String Interpolation vs String.Format
- Open a file and replace strings in C#
- Collection was modified; enumeration operation may not execute – why?
- Regex nested parentheses
- Adding a newline into a string in C#
- How can I create all possible combinations for a set of words without repetition?