C#控制台,Console.Clear问题 [英] c# console, Console.Clear problem
本文介绍了C#控制台,Console.Clear问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写在C#控制台程序。
I am writing a console program in C#.
有没有一种方法,我可以用一个Console.Clear()来唯一清楚某些事情在控制台屏幕上?
Is there a way I can use a Console.Clear() to only clear certain things on the console screen?
下面是我的问题:
我有一个标志(我把它在屏幕上使用Console.WriteLine() )和一个二维数组,我想保持它下面恒定,清晰的一切。
I have a logo (I put it on screen using Console.WriteLine()) and a 2d array which I want to keep constant and clear everything below it.
推荐答案
您可以使用自定义的方法来清除屏幕的部分...
You could use a custom method to clear parts of the screen...
static void Clear(int x, int y, int width, int height)
{
int curTop = Console.CursorTop;
int curLeft = Console.CursorLeft;
for (; height > 0;)
{
Console.SetCursorPosition(x, y + --height);
Console.Write(new string(' ',width));
}
Console.SetCursorPosition(curLeft, curTop);
}
这篇关于C#控制台,Console.Clear问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文