Subject subject=(Subject)Enum.Parse(typeof(Subject),"Logon");

解决方案 »

  1.   

    using System;public class ParseTest {
        [FlagsAttribute]
        enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };    public static void Main() {        Console.WriteLine("The entries of the Colors Enum are:");
            foreach(string s in Enum.GetNames(typeof(Colors)))
                Console.WriteLine(s);        Console.WriteLine();        Colors myOrange = (Colors)Enum.Parse(typeof(Colors), "Red, Yellow");
            Console.WriteLine("The myOrange value has the combined entries of {0}", myOrange);
        }
    }