<分区>
我正在尝试从 Type 枚举变量中获取所有枚举值:
[Flags]
enum Type
{
XML = 1,
HTML = 2,
JSON = 4,
CVS = 8
}
static void Main(string[] args)
{
Type type = Type.JSON | Type.XML;
List<Type> types = new List<Type>();
foreach (string elem in type.ToString().Split(',') )
types.Add( (Type)Enum.Parse( typeof(Type), elem.Trim() ) );
}
有更好的方法吗?