C # self-study Road 03

Source: Internet
Author: User

The first C # program

The first Console application. 650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/BC/wKiom1UjzErQHIsIAAEXTq9b-VM020.jpg "title=" k@r65_ CLJVKGV (4A5)%dhki.png "alt=" wkiom1ujzerqhisiaaextq9b-vm020.jpg "/> Output weclome, C #

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/B7/wKioL1Ujzf_ASFtWAACvWTbFH2A509.jpg "title="]~w_~{ YO) {P_U~QG5@%CB ' o.jpg "alt=" Wkiol1ujzf_asftwaacvwtbfh2a509.jpg "/>

The main () method in C # must be contained within a class.

Let's talk about input and output operations.

The input and output of the console is primarily implemented by the console class in the namespace system, which provides basic operation of read-write characters from the console, mainly through the read () method in the console class and the Read () method, Write (), WriteLine () method to implement the input and output.

Write () formats the output string in the form of {n,m: format string} .

N: Indicates the ordinal of the output variable.

M: Indicates the number of characters in the output variable, left-aligned with negative values, and a positive value of right alignment.

Formatted string: For the xn format, n represents the precision of the number.


A simple example: C or C is usually a symbol of currency,

Double k = 1234.789;

Console.WriteLine ("{0, 8:c}", K); Result is 1234

Console.WriteLine ("{0, 10:c4}", K); Result is 1234.7890


The difference between Console.Write () and Console.WriteLine () is that WriteLine () outputs more than one line break.

Console.read () reads a character from the input stream of the console and returns until the user presses the ENTER key.

Consolereadline () reads a row of data until a return key is encountered and the ENTER key is not accepted. Is that the information received by the output ReadLine () is not wrapped.


The first Windows window application.

When you click Show, the word above is displayed.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/B8/wKioL1Uj2Wrz6Y8WAAM-qmHqxiw335.jpg "title=" 0$hqj5 {42j5rp[@$5d7fhjx.png "alt=" wkiol1uj2wrz6y8waam-qmhqxiw335.jpg "/> See you tomorrow .........

This article is from the "very blog" blog, make sure to keep this source http://10093949.blog.51cto.com/10083949/1629815

C # self-study Road 03

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.