遍历枚举类型

            
            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);


你可能感兴趣的:(遍历枚举类型)