开发者

Maximum columns for a Console in C#

开发者 https://www.devze.com 2023-04-11 06:38 出处:网络
In a C# console application I have discovered th开发者_运维知识库at you can use Console.SetWindowSize(160, 80); to set the size of the console window. This is great, except for the fact that the maxim

In a C# console application I have discovered th开发者_运维知识库at 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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号