第八章:if-else语句

if-else语句:if是如果的意思,else是其他情况的意思

代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//if如果的意思,else是其他情况的意思

namespace if_else语句
{
    class Program
    {


        static void Main(string[] args)
        {
            string hello = "123";
            if (hello == "上午")
            {
                //写我们想要打印的语句
                Console.WriteLine("早上好!");
            }
            else if (hello == "中午")
            {
                Console.WriteLine("中午好!");
            }
            else if (hello == "晚上")
            {
                Console.WriteLine("晚上好!");
            }
            else
            {
                Console.WriteLine("休息中");
            }
            Console.Read();
        }
    }
}

运行结果:

 

posted @ 2020-06-04 18:08  进一步海阔天空  阅读(229)  评论(0编辑  收藏  举报