C#小白学习笔记(11)三目运算符

namespace Demo11_三目运算符
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入年龄:");
            int age = int.Parse(Console.ReadLine());
            string str;
            str = age < 18 ? "未成年!" : "已成年!"; //三目运算符必须要赋值
            Console.WriteLine(str);
            Console.ReadKey();
            
        }
    }

 

posted @ 2020-09-17 15:00  ___lucky  阅读(792)  评论(0)    收藏  举报