.NET中使用switch和java不一樣的地方。

來源:互聯網
上載者:User

標籤:沒有   textarea   tar   padding   target   頁面   ack   razor文法   border   

1.不能這樣貫穿

我們知道,java 和 C在使用switch時候可以這樣。

            switch (i)

            {

                //java中此處不使用break

                // 執行了case 1:對應的語句後直接 貫穿到 case 2:中的語句。

                case 1:

                    Console.WriteLine("111");

                case 2:

                    Console.WriteLine("222");

                    break;

                default:

                    Console.WriteLine("333");

                    break;

            }

但是C#中 這樣寫則會報錯。

C#中必須讓 每個有語句的case 都 有一個break。

像這樣

2. 是不是說C#中的 case就不能貫穿了呢?  不是的!

當某case語句中沒有代碼的時候,還是可以貫穿的。

        我要說的就是這些,不同的語言 總是會有一些小的不同。但是思想上是一致的。

每種語言都有自己的表達方式,求同而存異。

這些不一樣的地方說不上誰好誰壞。。。

如同世界上任何語言都能 ,唱出最美妙的歌曲一樣。

編程世界,沒有垃圾語言,只是使用的人蔘差不齊。

參考頁面:

http://www.yuanjiaocheng.net/mvc/mvc-views.html

http://www.yuanjiaocheng.net/Hibernate/first.html

http://www.yuanjiaocheng.net/webapi/web-api-host.html

http://www.yuanjiaocheng.net/ASPNET-CORE/core-actionresults.html

http://www.yuanjiaocheng.net/CSharp/csharp-extension-method.html

http://www.yuanjiaocheng.net/ASPNET-CORE/core-identity-migrations.html

http://www.yuanjiaocheng.net/ASPNET-CORE/core-setup-entityframework.html

http://www.yuanjiaocheng.net/mvc/bundling-and-minification-in-asp.net-mvc.html

http://www.yuanjiaocheng.net/mvc/mvc-razor-yufa.html

http://www.yuanjiaocheng.net/mvc/mvc-helper-TextArea.html

http://www.yuanjiaocheng.net/mvc/mvc-helper-textbox.html

.NET中使用switch和java不一樣的地方。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.