C#中,如何获取(遍历)枚举中所有的值:
public enum Suits { Spades, Hearts, Clubs, Diamonds, NumSuits } private static void Main(string[] args) { foreach (Suits suit in Enum.GetValues(typeof(Suits))) { Console.WriteLine((int)suit+ ":" + suit); } }
C#中,如何获取(遍历)枚举中所有的值:
public enum Suits { Spades, Hearts, Clubs, Diamonds, NumSuits } private static void Main(string[] args) { foreach (Suits suit in Enum.GetValues(typeof(Suits))) { Console.WriteLine((int)suit+ ":" + suit); } }
原文:https://www.cnblogs.com/chengqi521/p/8243016.html