Switch is different from java in. NET .,. Netswitch

Source: Internet
Author: User
Tags case statement

Switch is different from java in. NET .,. Netswitch

1. It cannot run like this

We know that java and C can do this when using the switch.

Switch (I)

{

// Break is not used here in java

// The statement corresponding to case 1 is executed and directly runs through the statement in case 2.

Case 1:

Console. WriteLine ("111 ");

Case 2:

Console. WriteLine ("222 ");

Break;

Default:

Console. WriteLine ("333 ");

Break;

}

But in C #, an error is returned.

In C #, each case with a statement must have a break.

Like this

2. Does it mean that case in C # cannot run through? No!

When there is no code in a case statement, it can still run through.

This is what I want to talk about. Different languages are always slightly different. However, they are ideologically consistent.

Each language has its own way of expression.

These are not the same...

Just like any language in the world, you can sing the most beautiful songs.

In the programming world, there is no spam language, but the use of people is uneven.

Reference page:

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.