Data Type Conversion

Source: Internet
Author: User

A lot of things are unsatisfactory and I feel so tired. sometimes I think about what it is for, but I still have to continue learning. I hope I can stick to it and I will be able to learn C # After graduation next year.

Int/double/string variable = Console. ReadLine ();

Int/double/string variable 1 = Convert. ToInt32 (variable );

The above two programs are equivalent to the following programs.

Int/double/string variable 1 = Convert. TOInt32 (Consol. ReadLine (); ------ enter the variable and Convert it to the corresponding type and assign the variable value to variable 1.

This statement converts the input characters to be converted to the int, double, or string type and then assigns them to the variable.

Convert. ToInt32 (); Convert to 32-Bit Signed int type.

Try

{

Conversion error may occur.

}

Catch

{

If an exception occurs in try, it is transferred to catch.

}

C # exception capture method.

Main (name = chinese = math = english = Console. WriteLine (, name, chinese + math + english, (chinese + math + english )/View Code Main (Console. writeLine (seconds = days = seconds/(* remainSecond = seconds % (*); hour = remainSecond/; remainSecond = remainSecond %; min = remainSecond/; second = remainSecond %View Code

 

Escape Character: \ n newline \ t Tab

\ B backspace \ output "\"

@ Adds an @ symbol to the front of the string, which has two meanings: (1) if \ is in the string, it is not understood as an escape character. (2) The string can be wrapped in a line break.

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.