Use switch case to determine how many days it is today

Source: Internet
Author: User
Tags switch case

static void Main (string[] args)
{
while (true)
{
int m1 = 31; int m2 = 28; int m3 = 31; int m4 = 30; int M5 = 31; int M6 = 30; int M7 = 31; int m8 = 31; int M9 = 30; int m10 = 31; int M11 = 30;


Console.Write ("Please enter the month");
int m = Convert.ToInt32 (Console.ReadLine ());
Console.Write ("Please enter the date");
int d = Convert.ToInt32 (Console.ReadLine ());
Switch (m)//If CASE1 is set up, simply jump out of the switch's curly brace and proceed directly to the next step. Switch followed by curly braces, case and break must be in conjunction with, and finally do not forget the default and break with the.
{
Case 1:
Console.Write ("+d+", "Day");
Break
Case 2:
Console.Write ("First" + (m1+ D) + "Day");
Break
Case 3:
Console.Write ("First" + (M1+M2+D) + "Day");
Break
Case 4:
Console.Write ("First" + (M1+M2+M3+D) + "Day");
Break
Case 5:
Console.Write ("First" + (M1+M2+M3+M4+D) + "Day");
Break
Case 6:
Console.Write ("First" + (M1 + m2 + m3 + m4+m5 + D) + "Day");
Break
Case 7:
Console.Write ("First" + (M1 + m2 + m3 + m4 + M5 +m6+ D) + "Day");
Break
Case 8:
Console.Write ("First" + (M1 + m2 + m3 + M4 + M5 + M6+M7 + D) + "Day");
Break
Case 9:
Console.Write ("First" + (M1 + m2 + m3 + M4 + M5 + M6 + M7+M8 + D) + "Day");
Break
Case 10:
Console.Write ("First" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8+m9 + D) + "Day");
Break
Case 11:
Console.Write ("First" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + M8 +m9+m10+ D) + "Day");
Break
Case 12:
Console.Write ("First" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + M9 + M10+m11 + D) + "Day");
Break
Default
Console.Write ("incorrect input");
Break

}

Console.ReadLine ();
}

Use switch case to determine how many days it is today

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.