我想輸入一個(gè)數(shù)字并讓控制臺程序從枚舉返回項(xiàng)目的名稱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貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超4個(gè)贊
int selection = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("{0} is {1} planet(s) from the sun", (planets)selection, selection);
- 1 回答
- 0 關(guān)注
- 138 瀏覽
添加回答
舉報(bào)
0/150
提交
取消