- enum enu { a=1, b=2, c=3, d=4 };
- private void button2_Click(object sender, System.EventArgs e) {
- //foreach
- foreach(string s in Enum.GetNames(typeof(enu))){
- MessageBox.Show(s);
- }
- foreach(int s in Enum.GetValues(typeof(enu))) {
- MessageBox.Show(s.ToString());
- }
- //to Array[]
- string[] en = Enum.GetNames(typeof(enu));
- Array ev = Enum.GetValues(typeof(enu));
- }
Enum遍历方法
最新推荐文章于 2024-07-30 11:17:53 发布