zoukankan      html  css  js  c++  java
  • ASP.NET第四天扫盲课

    第四天

    If()

    {

    语句块;

    }

    Else

    {

    语句块;

    }

    先判断条件的结果,如果条件的结果为true,则执行语句块;

    If  --  else if语句中,语句只执行一个

    最后一个不带if的语句可以省略,如果省略,上面的语句块都不成立,则一个语句都不执行;

    Swith语句;

    Swith(表达式/变量)

    {

    Case 常量;

    Break

    Case。。。

    Default语句;

    Break

    }

    输入年份和月份,输出天数:

    int day = 31;

                Console.WriteLine("请输入年份:");

                int year = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("请输入月份:");

                int yue = Convert.ToInt32(Console.ReadLine());

                switch (yue)

                {

                    case 1:case 3:case 5:case 7:case 8:case 10:case 12:

                        break;

                    case 4:case 6:case 9:case 11:

                        day = 30;

                        break;

                    case 2:

                        if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))

                        {

                            day = 29;

                        }

                        else

                        {

                            day = 28;

                        }

                        break;

                }

                Console.WriteLine("你输入的{0}年{1}月,是{2}天", year, yue, day);

    try捕获并抛出异常;

    {

    可能出现问题的语句;

    }

    Catch

    {

    说明问题所在;

    }

    哪种方式方便快捷就用哪种方法,不要有什么固定的思维方式;

  • 相关阅读:

    es -Aggregations
    散列表学习
    SpringCloud (一)——基本的搭建
    1.5 中不支持 lambda 表达 java
    区块链 (一)——基础
    线性表
    Redis(四)——消息队列
    rune is alias of int32
    wall time
  • 原文地址:https://www.cnblogs.com/mafacai/p/2806338.html
Copyright © 2011-2022 走看看