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/zhangzhi19861216/p/5362090.html
,