gpt4 book ai didi

c# - 如何设置最小控制台大小 C#?

转载 作者:太空宇宙 更新时间:2023-11-03 12:17:20 24 4
gpt4 key购买 nike

如何在控制台应用程序 C# 中设置用户无法更改的最小控制台大小?预先感谢您的回答;)

最佳答案

控制台没有任何调整大小事件。但作为解决方法,您可以尝试(不推荐!):

public static void Main(string[] args)
{
const int MinHeight = 10;
const int MinWidth = 10;
Task.Factory.StartNew(() =>
{
while (true)
{
if (Console.WindowHeight > MinHeight || Console.WindowWidth > MinWidth)
{
Console.SetWindowSize(MinWidth, MinHeight);
}
}
});
// Do some work here
Console.ReadKey();
}

关于c# - 如何设置最小控制台大小 C#?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49130432/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com