zoukankan      html  css  js  c++  java
  • 第八章: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();
            }
        }
    }

    运行结果:

  • 相关阅读:
    抽象类
    类初始化
    final关键字
    super关键字
    继承
    常用类

    封装
    方法重载
    031:Cetus sharding
  • 原文地址:https://www.cnblogs.com/wangqiangya/p/13045212.html
Copyright © 2011-2022 走看看