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 ){}