
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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
- Related Articles
- Reading data from keyboard using console class in Java
- How to use WriteLine() method of Console class in C#?
- How to use ReadKey() method of Console class in C#?
- How to read data from user using the Console class in Java?
- How to clear console in C?
- Read integers from console in Java
- How to clear console in MongoDB?
- Taking input from console in Python
- Explain all Console Object in HTML
- C# Console BufferHeight Property
- C# Console BufferWidth Property
- What is Postman Console?
- Display data as table in browser console
- Way to read input from console in C#
- Ways to read input from console in Java

Advertisements