C#遍历枚举类型

  

string[] enumNames = Enum.GetNames(typeof(Environment.SpecialFolder));
foreach (var name in enumNames)
{
  Console.WriteLine(name);
}

var arr = Enum.GetValues(typeof(Environment.SpecialFolder));
foreach (var item in arr)
{
  Console.WriteLine(Environment.GetFolderPath((Environment.SpecialFolder)item));
}

string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
Console.WriteLine(dir);

  

posted @ 2013-05-31 23:42  liqipeng  阅读(170)  评论(0编辑  收藏  举报