Để 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ả
