我想輸入一個數字并讓控制臺程序從枚舉返回項目的名稱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 關注
- 144 瀏覽
添加回答
舉報
0/150
提交
取消