Thuộc tính WindowWidth lấy hoặc đặt chiều rộng của cửa sổ bảng điều khiển.
Khai báo một biến.
int width;
Bây giờ, hãy lấy chiều rộng của cửa sổ hiện tại.
width = Console.WindowWidth;
Sau đây là ví dụ đầy đủ.
Ví dụ
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);
}
} Đầu ra
Current window width = 0 Current window height = 0