我想输入一个数字并让控制台程序从枚举返回项目的名称using System;namespace ConsoleApp7{ class Program { enum planets { Mercury = 1, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune}; static void Main(string[] args) { int selection = Convert.ToInt32(Console.ReadLine()); selection = enum planets; Console.WriteLine("{0} is {1} planet(s) from the sun", planets, selection); Console.Readkey(); } }}
1 回答
慕容708150
TA贡献1831条经验 获得超4个赞
int selection = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("{0} is {1} planet(s) from the sun", (planets)selection, selection);
- 1 回答
- 0 关注
- 93 浏览
添加回答
举报
0/150
提交
取消