Branch statement (switch case)

Source: Internet
Author: User
Tags switch case

Application of/switch case
Console.WriteLine ("1. Hamburger");
Console.WriteLine ("2. French fries");
Console.WriteLine ("3. Chicken nuggets");
Console.WriteLine ("4. Chicken Leg");
Console.WriteLine ("5. Chicken rice flower");

Console.Write ("Please enter your choice of item number:");
String a = Console.ReadLine ();

Switch (a)//in parentheses is the variable name that is judged
{
Case "1": The value behind the//case is used to determine that the variables in the brackets above are not equal
Console.WriteLine ("You have chosen a hamburger");
Break;//break Jump statement, jump out of the nearest curly brace
Case "2": a space-separated value between the//case and the value is followed by a colon
Console.WriteLine ("Your choice is French fries");
Break
Case "3":
Console.WriteLine ("You have selected chicken nuggets");
Break
Case "4":
Console.WriteLine ("Your choice is chicken leg");
Break
Case "5":
Console.WriteLine ("Your choice is chicken rice flower");
Break The last one also needs to jump out of curly braces
}

Branch statement (switch case)

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.