Loop, jump, exception statement, String class, Math, datetime

Source: Internet
Author: User

1. Circular statements

(1) for

(2) while

(3) Do... while ... ..

(4) for each

(1) for(initial condition; comparison; state change)

{

Circulation body;

}

(2)int i=0;// Initial conditions

While(i<=9)

{

Circulation body;

i++;// change of State

}

(3)int i=0;

Do

{

i++;

Circulation body;

}while(i<0);

Note: do ... while ..... Performed first, in judgment.

2. Jump statement

Break interrupts the current most recent loop;

Continue interrupts the section behind this cycle and jumps directly to the state, continuing the loop below.

3. Exception statement

Try

{

Code

}

Catch(execption e)// Save the caught exception to the variable e of the exception class in

{

Console.WriteLine (E.message);

}

Finally

{

Console.WriteLine ("");

}

Note: Thefinally will be executed regardless of whether the above is wrong.

String class

(1). length// Gets the length of the current string, returning an int value

(2). Trim ()// Remove the space before and after the string

(3). TrimStart ()// Remove the spaces in front of the string

(4). TrimEnd ()// Remove the space following the string

(5). Toupper ()// convert to uppercase

(6). Tolower ()// convert to lowercase

(7). IndexOf ()// returns the position of the first occurrence of a string in a string that matches the condition (the index starts at 0 )

(8). LASTINDEXOF ()// returns the position of the last occurrence of the qualifying string in the string (index starting at 0 )

(9). StartsWith ()// start of judgment, return bool Type value

(Ten). EndsWith ()// judgment end, return bool Type value

(one). Contains ()// determine if a character segment is included in the string and return the bool Type value

(). substring (,)// intercept the specified length of the character segment from the specified index, if only one number is written, which means that it is truncated from this position to the last

(). ToString ("#.00")//

Math

(1) math.celling ()// Upper limit rounding

(2) Math.floor ()// lower bounds rounding

(3) Math.PI ()//π value

(4) Math.Round ()// rounding

(5) MATH.SQRT ()// prescribe

(6) Math.Abs ()// take absolute value

Datetime

(1) DateTime d=new datetime ();// creation time

(2) Datetime d=datetime.now;// Fetch Current Time

(3) add// plus a certain amount of time

Addyears () Addmonths () Adddays () Addhours () addticks ()

AddMinutes () addseconds () Addmilliseconds ()

(4). dayofyear// Returns the day ordinal of a year

(5). dayofweek// Returns the day of the week

. ToString ("yyyy year ")

. ToString ("MM month ")

. ToString ("DD Day ")

. ToString ("HH ")

. ToString ("mm- min ")

. ToString ("ss seconds ")

Console.clear ();// empty

Thread.Sleep ();// delay (To reference using System.Threading)

Loop, jump, exception statement, String class, Math, datetime

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.