String的三元表达式
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ConsoleApp1 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 Console.WriteLine("请输入姓名:"); 14 String name = Console.ReadLine(); 15 16 String result = name == "乙烯" ? "人才" : "流氓"; 17 Console.WriteLine(result); 18 Console.ReadKey(); 19 20 21 22 23 24 25 } 26 } 27 }