C # Notes (ii)--input and output functions

Source: Internet
Author: User

One: Input function:

1:

String a = Console.ReadLine (); Place the input string into the variable A;

2:

int a = Console.read (); The ASC code of the first character of the input string is stored in the shaping variable A;

Two: Line break (execution on the next line): Console.WriteLine ();

Input: int a = 9;
Console.WriteLine ();
Console.WriteLine ();
Console.WriteLine (a);

Three: Formatted output

A: Enter:

int a = 1;int b = 2;int c = 3;
Console.WriteLine ("A={0},b={1},c={2}", a,b,c);

Output:

B: Enter:

FLOAT score = 23.5f;
f indicates a few digits after the decimal point and can be appended with numbers
Console.WriteLine ("Score={0:f2}", score);
Console.WriteLine ("score={0:0.000}", score);

Output:


C: Input

Convert the data to a% form and keep two decimal bit Console.            WriteLine ("{0:p2}", 1/4f); If the string is preceded by @, the escape character inside the string fails the Console.            Write (@ "lanoukeji\n"); Console. Write ("Hello World");


C # Notes (ii)--input and output functions

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.