三目运算符多值判断
1 //0成功 1失败 2异常 3正常 4上线 5下线 2 while (true) 3 { 4 Console.Write("请输入a的值:"); 5 int a = Convert.ToInt32(Console.ReadLine()); 6 Console.WriteLine(a == 0 ? "成功" : (a == 1 ? "失败" : (a == 2 ? "异常" : (a == 3 ? "正常" : (a == 4 ? "上线" : (a == 5 ? "下线" : "未知")))))); 7 }