Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Console Class in C#
The Console class in C# is used to represent the standard input, output, and error streams for console applications.
Let us see some examples of Console class properties in C# −
Console.CursorLeft property
To change the CursorLeft of the Console in C#, use the Console.CursorLeft property.
Example
Let us see an example −
using System;
class Demo {
public static void Main (string[] args) {
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("Background color changed = "+Console.BackgroundColor);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("
Foreground color changed = "+Console.ForegroundColor);
Console.CursorLeft = 30;
Console.Write("CursorLeft position: "+Console.CursorLeft);
}
}
Output
This will produce the following output −

Console.CursorSize property
To change the CursorSize of the Console in C#, use the Console.CursorSize property in C#.
Example
Let us see an example −
using System;
class Demo {
public static void Main (string[] args) {
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("Background color changed = "+Console.BackgroundColor);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("
Foreground color changed = "+Console.ForegroundColor);
Console.CursorSize = 1;
Console.WriteLine("
CursorSize = "+Console.CursorSize);
}
}
Output
This will produce the following output −

Console.BufferWidth property
To change the BufferWidth of the Console, use the Console.BufferWidth property.
Example
Let us now see an example −
using System;
class Demo {
public static void Main (string[] args) {
Console.BufferHeight = 200;
Console.WriteLine("Buffer Height = "+Console.BufferHeight);
Console.BufferHeight = 250;
Console.WriteLine("Buffer Width = "+Console.BufferWidth);
}
}
Output
This will produce the following output −
Buffer Height = 200 Buffer Width = 200
Advertisements