Customizing the Appearance of the Console Window in C#



 

 

 

 

Console Class
The Console class provides basic support for applications that read characters from, and write characters to, the console. The Console class also includes members that support customization of the appearance of the console window itself. You can call the SetWindowSize method to change the number of rows and columns in the console window at the same time, or you can use the WindowHeight and WindowWidth properties to change the number of rows and columns independently of one another. You can use the ForegroundColor and BackgroundColor properties to control the color of the console window, and you can use the CursorSize and CursorVisible properties to customize the cursor in the console window.
Unfortunately, some methods of this class are not working correctly in Windows 7, or Windows 8. For example, if you want to move the Console window to the top left corner of your screen, you may write Console.SetWindowPosition(0, 0), but it does not move the window to this coordinate. You can use Windows API to address this problem. The follwoing examples show how to customize the appearance of the console window.

Creating a Fullscreen Console Window

The output is shown below:

Copyright © All Rights Reserved - C# Learners