更改控制台窗口的大小会抛出ArgumentOutOfRangeException [英] Changing Console Window's size throws ArgumentOutOfRangeException

查看:938
本文介绍了更改控制台窗口的大小会抛出ArgumentOutOfRangeException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在c#控制台应用程序中设置控制台窗口的大小。我收到此消息的 ArgumentOutOfRangeException

I am trying to set the size of the Console Window in a c# console application. I get an ArgumentOutOfRangeException with this message:


该值必须小于控制台的当前最大窗口大小
在该维度中为41。请注意,此值取决于屏幕
分辨率和控制台字体。

The value must be less than the console's current maximum window size of 41 in that dimension. Note that this value depends on screen resolution and the console font.

我使用此设置: p>

I am using this to set it:

Console.WindowHeight = 480;

如何正确设置控制台窗口的大小?

How do you set the Console window's size properly?

推荐答案

MSDN .aspxrel =nofollow> Console.WindowHeight 属性:

From MSDN of Console.WindowHeight property:


以行为单位测量的控制台窗口的高度。

The height of the console window measured in rows.

正如你所看到的, em>。请记住,这些值可能会根据您的屏幕分辨率和控制台字体而改变。您可以使用 height 和 width 值。 aspxrel =nofollow> Console.LargestWindowWidth Console.LargestWindowHeight 属性。

As you can see, these are not pixels. Just remember, these values can change depending on your screen resolution and the console font. You can find maximum height and width values with Console.LargestWindowWidth and Console.LargestWindowHeight properties.

Console.WriteLine(Console.LargestWindowHeight);
Console.WriteLine(Console.LargestWindowWidth);

这篇关于更改控制台窗口的大小会抛出ArgumentOutOfRangeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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