คุณสมบัติ WindowWidth รับหรือตั้งค่าความกว้างของหน้าต่างคอนโซล
ประกาศตัวแปร
int width;
ตอนนี้ หาความกว้างของหน้าต่างปัจจุบัน
width = Console.WindowWidth;
ต่อไปนี้เป็นตัวอย่างที่สมบูรณ์
ตัวอย่าง
using System;
using System.Numerics;
using System.Globalization;
class Demo {
static void Main() {
int width;
int height;
width = Console.WindowWidth;
height = Console.WindowHeight;
Console.WriteLine("Current window width = "+width);
Console.WriteLine("Current window height = "+height);
}
} ผลลัพธ์
Current window width = 0 Current window height = 0