คุณสมบัติ WindowsTop ใช้เพื่อรับหรือตั้งค่าตำแหน่งบนสุดของพื้นที่หน้าต่างคอนโซลที่สัมพันธ์กับบัฟเฟอร์หน้าจอ
ประกาศตัวแปรจำนวนเต็มเพื่อรับตำแหน่งบนสุด
int top;
ตอนนี้ ใช้คุณสมบัติ Console.WindowTop
top = Console.WindowTop;
มาดูตัวอย่างฉบับสมบูรณ์กันเถอะ
ตัวอย่าง
using System;
class Demo {
static void Main() {
int top;
top = Console.WindowTop;
Console.WriteLine("Top position of the Console window = "+top);
}
} ผลลัพธ์
Top position of the Console window = 0