zoukankan      html  css  js  c++  java
  • c#笔记(四)——switch

    switch (date)
                {
                    case 1:
                        Console .WriteLine("周一" );
                        break ;
                    case 2:
                        Console .WriteLine("周二" );
                        break ;
                    case 3:
                        Console .WriteLine("周三" );
                        break ;
                    case 4:
                        Console .WriteLine("周四" );
                        break ;
                    case 5:
                        Console .WriteLine("周五" );
                        break ;
                    case 6:
                        Console .WriteLine("周六" );
                        break ;
                    case 7:
                        Console .WriteLine("周日" );
                        break ;
                    default :
                        Console .WriteLine("大保健" );
                        break ;
                }
    1.switch里面可以没有default语句块,如果所有的case都不符合要求时
                会直接跳出switch开关
                2.如果case后面有语句,则一定要有break
                3.如果case后面没有任何代码,它会和他后面的case共用一段代码
                4.default的位置是随意的
                5.case的位置不确定
  • 相关阅读:
    day32-python阶段性复习六
    golang 项目中坑
    golang crawler
    router
    golang in ubuntu
    go channel 案例分析
    go channel learning
    bee go + mgo
    URL escape and unescape
    [转]good sample of Go
  • 原文地址:https://www.cnblogs.com/ningyongbin/p/5922059.html
Copyright © 2011-2022 走看看