C # general Review

Source: Internet
Author: User
Tags switch case

int a = 5;
a++;
++a;
Console.WriteLine (a);
Console.ReadLine ();

int a = 5;
int b = ++a;//a=a+1;int b=a;
int c = A++;//int c=a;a=a+1;
int b = a++;
int c = ++a;
Console.WriteLine (A + "\ t" +b+ "\ T" +c);
Console.ReadLine ();


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


branch
format 1:if () {} If satisfied, skip

format 3:if () {} else if () {} ... else{} multiple Select a
format 4:if nested after a wide range of rules what's the small case
switch case in relation to the format of the multiple-choice one
all switch Case can be written as if else
but not all if else can be written as switch cases


Looping statements
Four elements: initial conditions, cyclic condition, cyclic body, state change
For loop
for (int i = 0; i < 5; i++)
{
Console.WriteLine ("Hello");
}
Console.ReadLine ();

Nesting for loops
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 loops can solve
Exhaustive: Go through all the possible scenarios and use if to filter out the required conditions
Iteration: Using the existing conditions to solve the intermediate situation, and finally deduce the results

While loop
int i = 0;
while (I < 5)
{
Console.WriteLine ("Hello");
i++;
}

Do While
Regardless of the expression after the time, you need to go through the first step
int a = 5;
do{
Console.WriteLine ("Hello");
}while (A>10);
Console.ReadLine ();


function Format
Format 1: No parameter no return public void Hanshu () {}
Format 2: No parameter has return public int Hanshu () {return 1;}
Format 3: The parameter is returned to public int Hanshu (int a) {return 1;}
Format 4: Parameter no return public void Hanshu (int a) {}

C # general Review

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.