C # general review,

Source: Internet
Author: User
Tags switch case

C # general review,

Int a = 5;
A ++;
++;
Console. WriteLine ();
Console. ReadLine ();

Int a = 5;
// Int B = ++ a; // a = a + 1; int B =;
// Int c = a ++; // int c = a; a = a + 1;
Int B = a ++;
Int c = ++;
Console. WriteLine (a + "\ t" + B + "\ t" + c );
Console. ReadLine ();


Int a = 8;
A + = 5; // a = a + 5;
Console. WriteLine ();

Statement classification: sequence, branch, and loop
Branch
Format 1: if () {}
Format 2: select either if () {} else {}
Format 3: if () {} else if () {}... else {} select one more
Format 4: What is the small size of if nesting after a large range is specified?
Select one of the switch cases specified by Format 3.
All switch cases can be written as if else.
But not all if else can be written as switch case


Loop statement
Four elements: initial condition, cyclic condition, cyclic body, and state change
For Loop
For (int I = 0; I <5; I ++)
{
Console. WriteLine ("Hello ");
}
Console. ReadLine ();

For loop nesting
Print Matrix
For (int I = 0; I <5; I ++)
{
For (int j = 0; j <5; j ++)
{
Console. Write ("■ ");
}
Console. WriteLine ();
}
Console. ReadLine ();

Types of problems that can be solved by Loops
Example: use if to filter out all possible conditions.
Iteration: Use existing conditions to continuously solve intermediate conditions, and finally export the results

While Loop
Int I = 0;
While (I <5)
{
Console. WriteLine ("Hello ");
I ++;
}

Do while
Whether it is full or not, you must execute the while expression first.
Int a = 5;
Do {
Console. WriteLine ("hello ");
} While (a> 10 );
Console. ReadLine ();


Function Format
Format 1: public void hanshu (){}
Format 2: return public int hanshu () {return 1 ;}
Format 3: return public int hanshu (int a) {return 1 ;}
Format 4: public void hanshu (int ){}

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.