语法
Code=C#
[ComVisibleAttribute(true)]
public static Object Parse (
Type enumType,
string value
)
C# 复制代码
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);
}
}