Today on the Internet to see someone to give such a program needs, bloggers take memories of the use of switch in C #
The program needs are as follows:
According to the Day of the week (one ~ th), the export of special dishes
"One", "two", "three", output "dry stir lentils 6 yuan."
"Four", "five", output "garlic lettuce dish 4 yuan."
"Six", "Day", output "saliva chicken 8 yuan."
Other, output "the number of weeks you entered is incorrect"
Action: Please use switch to export the Specials menu.
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceConsoleApp18 {9 class ProgramTen { One Static voidMain (string[] args) A { - stringDay =""; -Console.Write ("Please enter the number of weeks:"); theDay =console.readline (); - Switch(Day) - { - Case "a": + Case "two": - Case "three": +Console.WriteLine ("dried stir lentils 6 yuan."); A Break; at Case "Four": - Case "Five": -Console.WriteLine ("4 yuan of garlic lettuce dish."); - Break; - Case "Six": - Case "Day": inConsole.WriteLine ("Spit Chicken 8 yuan."); - Break; to default: +Console.WriteLine ("the number of weeks you entered is incorrect"); - Break; the } * Console.readkey (); $ }Panax Notoginseng } -}
Use of switch in C #