Lớp Console trong C# đại diện cho các luồng đầu vào, đầu ra và lỗi tiêu chuẩn cho ứng dụng console.
Dưới đây là một số ví dụ về các thuộc tính của lớp Console trong C#:
Thuộc tính Console.CursorLeft
Để thay đổi vị trí con trỏ ngang của Console trong C#, sử dụng thuộc tính Console.CursorLeft.
Ví dụ
using System;
class Demo {
public static void Main (string[] args) {
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("Màu nền đã thay đổi = " + Console.BackgroundColor);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\nMàu chữ đã thay đổi = " + Console.ForegroundColor);
Console.CursorLeft = 30;
Console.Write("Vị trí CursorLeft: " + Console.CursorLeft);
}
}
Kết quả

Thuộc tính Console.CursorSize
Để thay đổi kích thước con trỏ của Console trong C#, sử dụng thuộc tính Console.CursorSize.
Ví dụ
using System;
class Demo {
public static void Main (string[] args) {
Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("Màu nền đã thay đổi = " + Console.BackgroundColor);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\nMàu chữ đã thay đổi = " + Console.ForegroundColor);
Console.CursorSize = 1;
Console.WriteLine("\nCursorSize = " + Console.CursorSize);
}
}
Kết quả

Thuộc tính Console.BufferWidth
Để thay đổi chiều rộng bộ đệm của Console, sử dụng thuộc tính Console.BufferWidth.
Ví dụ
using System;
class Demo {
public static void Main (string[] args) {
Console.BufferHeight = 200;
Console.WriteLine("Chiều cao bộ đệm = " + Console.BufferHeight);
Console.BufferHeight = 250;
Console.WriteLine("Chiều rộng bộ đệm = " + Console.BufferWidth);
}
}
Kết quả
Chiều cao bộ đệm = 200 Chiều rộng bộ đệm = 200