If statement and switch case

Source: Internet
Author: User
Tags switch case try catch

Statement:
Branching statements: if,if else,if ElseIf else,switch case
Looping statements: For,while,do While,foreach
Jump statement: Break,continue
Exception statement: Try Catch finally
Branch statements:
int a=5;
if (a>0)
{
Console.WriteLine ("This is a positive number");
}
Esle//If the a<=0 is executed, the subsequent statement is performed and the subsequent statement is always executed if no else is added
{
Console.WriteLine ("This is a number less than or equal to 0");
}
else if (a>10)
{
Console.WriteLine ("This is a number greater than 10");
}
2014-12-11
If statement
Title (1) Enter the year to determine whether it is leap years
(2) Determine if a date is correct
(3) Determine if weight is a standard weight
(4) and computer scissors
(5) Judging the equation of one yuan and two times
Switch case
int I=int. Parse (Console.ReadLine ());
Switch (i)
{
Case 1:
Console. WriteLine ("Monday");
Break
Case 2:
Console. WriteLine ("Tuesday");
Break
Case 3:
Console. WriteLine ("Wednesday");
Break
Case 4:
Console. WriteLine ("Thursday");
Break
Case 5:
Console. WriteLine ("Friday");
Break
Default
Console. WriteLine ("You may have entered incorrectly");
Break
Calculate the day ordinal of a year
Console.WriteLine ("Please enter the Year");
int year = Int. Parse (Console.ReadLine ());
Console.WriteLine ("Please enter the month");
int month = Int. Parse (Console.ReadLine ());
Console.WriteLine ("Please enter the day");
int day = Int. Parse (Console.ReadLine ());
int sum=0;
If ((year% 4 = = 0 && Year% 100! = 0) | | (year%400==0))
Switch (month)
{
Case 1:
Sum=day;
Break
Case 2:
Sum=31+day;
Break
Case 3:
..................

If statement and 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.