C # System.Console Class of nuclear coding

Source: Internet
Author: User

As the name implies, the console class encapsulates the operation of the console-based input output and error flow, and the following lists some of the common members of the System.Console class that can add some "spice" to a simple command-line program, such as changing the background color and foreground color, and emitting a spike at various frequencies. The code is as follows:

            //Console.beep (666, 6000);//let the console beep at various frequenciesConsole.backgroundcolor = Consolecolor.green;//console input row background colorConsole.foregroundcolor = Consolecolor.yellow;//set the color of the console's charactersConsole.bufferheight = -;//sets the height of the bufferConsole.bufferwidth = -;//sets the width of the bufferConsole.windowwidth = the;//Setting the width of the consoleConsole.windowheight = -;//set the height of the consoleConsole.windowleft =5;//Gets or sets the position of the leftmost portion of the console window area relative to the screen bufferConsole.windowtop =5;//Gets or sets the position of the top of the console window area relative to the screen bufferConsole.clear ();//clears the display information for the console buffer and the corresponding console window. 

Use the console class for basic input and output:

 Static voidMain (string[] args) {            //showenvironmentdetails (); //Showdigitofsystem (); //showmethodofconsole ();Console.WriteLine ("Basic Console I/O");            Getuserdata ();        Console.ReadLine (); }        Static voidGetuserdata () {Console.WriteLine ("Please enter your name:"); stringUserName =Console.ReadLine (); Console.WriteLine ("Please enter your age:"); stringUserage =Console.ReadLine (); Consolecolor Prevcolor=Console.foregroundcolor; Console.foregroundcolor=Consolecolor.green; Console.WriteLine ("Hello {0} you are {1} years old!", UserName, userage); Console.foregroundcolor=Prevcolor; }

C # System.Console Class of nuclear coding

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.