在C#控制台最大列 [英] Maximum columns for a Console in C#

查看:274
本文介绍了在C#控制台最大列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

  Screen.PrimaryScreen.Bounds.Width
 

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

解决方案

  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

这篇关于在C#控制台最大列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆