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

การรับความสูงและความกว้างหน้าต่างสูงสุดของ Console ใน C#

ภาพรวม

คุณสมบัติ Console.LargestWindowHeight และ Console.LargestWindowWidth คืนขนาดหน้าต่างคอนโซลสูงสุดที่ระบบรองรับ (ขึ้นกับความละเอียดหน้าจอและฟอนต์)

ตัวอย่าง 1: ความสูงสูงสุด

using System;

public class Demo {
    public static void Main(string[] args) {
        Console.WriteLine("Largest Window Height of the Console = " + Console.LargestWindowHeight);
    }
}

ผลลัพธ์ตัวอย่าง 1

Largest Window Height of the Console = 58

ตัวอย่าง 2: ความกว้างสูงสุด

using System;

public class Demo {
    public static void Main(string[] args) {
        Console.WriteLine("Largest Window Width of the Console = " + Console.LargestWindowWidth);
    }
}

ผลลัพธ์ตัวอย่าง 2

Largest Window Width of the Console = 190

สรุป

  • ค่าขึ้นกับระบบปฏิบัติการ ความละเอียดหน้าจอ และขนาดฟอนต์คอนโซล
  • ใช้ตั้งค่า Console.WindowHeight และ Console.WindowWidth ไม่เกินค่านี้
  • อ่านอย่างเดียว (read-only)