Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

วิธีเปลี่ยน CursorTop ของ Console ใน C#


หากต้องการเปลี่ยนตำแหน่งแนวตั้งของเคอร์เซอร์ใน C# ให้ใช้คุณสมบัติ Console.CursorTop

ตัวอย่าง

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("\nForeground color changed = " + Console.ForegroundColor); 
        Console.CursorTop = 20; 
        Console.WriteLine("\nCursorTop = " + Console.CursorTop); 
    } 
}

ผลลัพธ์

วิธีเปลี่ยน CursorTop ของ Console ใน C#