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
原文地址:https://www.cnblogs.com/chengqi521/p/8243016.html
时间: 2024-10-17 12:10:46