CSharp examples for System:Enum
Get Enum Value
using System.Xml.Serialization; using System.Threading.Tasks; using System.Text; using System.Linq; using System.IO;//from w w w . j a v a2 s. c o m using System.Collections.Generic; using System; public class Main{ public static T GetEnumValue<T>(String value) { var found = typeof(T).GetEnumValues().Cast<Enum>().FirstOrDefault(x => GetNameValue(x) == value); T result = default(T); if (found is T) { result = (T)(object)found; } return result; } }