?:classProgram{staticvoidMain(string[]args){intmyInt=50;stringre=(myInt<10)?"條件成立":"條件不成立";Console.WriteLine("{0}",re);Console.ReadKey();}}if語句重寫上述案例:cl" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

分支

系統(tǒng) 2253 0

分支是控制下一步執(zhí)行哪行代碼的過程。三元運(yùn)算符;if語句;switch語句

三元運(yùn)算符:

<test> ?? <resultiftrue>? :? <resultiffalse>

      
        class
      
      
         Program

    {

        
      
      
        static
      
      
        void
      
       Main(
      
        string
      
      
        [] args)

        {

            
      
      
        int
      
       myInt = 
      
        50
      
      
        ;

            
      
      
        string
      
       re=(myInt < 
      
        10
      
      ) ? 
      
        "
      
      
        條件成立
      
      
        "
      
      
        

                : 
      
      
        "
      
      
        條件不成立
      
      
        "
      
      
        ;

            Console.WriteLine(
      
      
        "
      
      
        {0}
      
      
        "
      
      
        , re);

            Console.ReadKey();

        }

    }
      
    

if語句重寫上述案例:

      
        class
      
      
         Program

    {

        
      
      
        static
      
      
        void
      
       Main(
      
        string
      
      
        [] args)

        {

            
      
      
        int
      
       myInt = 
      
        50
      
      
        ;

            
      
      
        if
      
       (myInt < 
      
        10
      
      
        )

            {

                Console.WriteLine(
      
      
        "
      
      
        條件成立
      
      
        "
      
      
        );

            }

            
      
      
        else
      
      
         {

                Console.WriteLine(
      
      
        "
      
      
        條件不成立
      
      
        "
      
      
        );

            }

            

            Console.ReadKey();

        }

    }
      
    

switch案例:

      
        class
      
      
         Program

    {

        
      
      
        static
      
      
        void
      
       Main(
      
        string
      
      
        [] args)

        {

            
      
      
        int
      
       x = 
      
        55
      
      
        ;

            
      
      
        switch
      
      
         (x) { 

                
      
      
        case
      
      
        7
      
      
        :

                    Console.WriteLine(
      
      
        "
      
      
        7
      
      
        "
      
      
        );

                    
      
      
        break
      
      
        ;

                
      
      
        case
      
      
        8
      
      
        :

                    Console.WriteLine(
      
      
        "
      
      
        8
      
      
        "
      
      
        );

                    
      
      
        break
      
      
        ;

                
      
      
        default
      
      
        :

                    Console.WriteLine(
      
      
        "
      
      
        沒有找到對(duì)應(yīng)數(shù)據(jù)
      
      
        "
      
      
        );

                    
      
      
        break
      
      
        ;

            }

            Console.ReadKey();

        }

    }
      
    

?

?

分支


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 新疆| 道真| 大余县| 永泰县| 高平市| 图木舒克市| 亚东县| 彭阳县| 满洲里市| 南岸区| 中牟县| 孝昌县| 榆社县| 合川市| 格尔木市| 沅江市| 新晃| 保康县| 廊坊市| 烟台市| 伊吾县| 霍城县| 界首市| 安阳县| 云梦县| 金乡县| 丹凤县| 盐池县| 施秉县| 宾川县| 德惠市| 卓资县| 辽阳县| 五原县| 呈贡县| 正安县| 新郑市| 肇东市| 太谷县| 远安县| 濉溪县|