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