在C#控制台最大列控制台、最大

2023-09-03 05:52:17 作者:奔跑的五花肉

在一个C#控制台应用程序我发现,您可以使用 Console.SetWindowSize(160,80); 设置控制台窗口的大小。这是很大的,除了事实行和列的最大数量是完全依赖于人的计算机的显示分辨率。

当你调用 Console.SetWindowSize()和供应值太高的应用程序将引发错误,并告诉你什么是最大列数即可。此最大数是不同,这取决于您的屏幕分辨率。如果 SetWindowSize()使用的像素则获得最大就容易了。

  Screen.PrimaryScreen.Bounds.Width
 
1 C 创建控制台应用程序

然而,它不使用的像素。它采用列。有什么方法来确定控制台列该最大值?

解决方案

  Console.LargestWindowWidth
Console.LargestWindowHeight
 

In a C# console application I have discovered that you can use Console.SetWindowSize(160, 80); to set the size of the console window. This is great, except for the fact that the maximum number of rows and columns is entirely dependent on the display resolution of the person's computer.

When you call Console.SetWindowSize() and supply values that are too high the application throws an error and tells you what the maximum number of columns can be. This maximum number is different depending on your screen resolution. If SetWindowSize() used pixels then getting the max would be easy.

Screen.PrimaryScreen.Bounds.Width

However, it doesn't use pixels. It uses columns. Is there any way to determine this max value for the console columns?

解决方案

Console.LargestWindowWidth
Console.LargestWindowHeight