控制台应用程序C#-刷新页面

控制台应用程序C#-刷新页面,c#,console-application,do-while,C#,Console Application,Do While,我基本上是在写一个带有欢迎屏幕的程序。底部写着“按一个键继续:”。但是,我想做的是让用户输入任意键,然后让控制台擦除上面的“欢迎屏幕”并继续程序 我尝试了DoWhile循环,但我只希望欢迎屏幕循环一次,然后停止。它所做的一切似乎就是不断打印欢迎屏幕,直到我按下某个按钮 任何帮助都会很好 谢谢 这就是我的代码到目前为止的样子 Console.WriteLine(""); Console.WriteLine("Press any key to Continue"); do { while

我基本上是在写一个带有欢迎屏幕的程序。底部写着“按一个键继续:”。但是,我想做的是让用户输入任意键,然后让控制台擦除上面的“欢迎屏幕”并继续程序

我尝试了DoWhile循环,但我只希望欢迎屏幕循环一次,然后停止。它所做的一切似乎就是不断打印欢迎屏幕,直到我按下某个按钮

任何帮助都会很好

谢谢

这就是我的代码到目前为止的样子

Console.WriteLine("");
Console.WriteLine("Press any key to Continue");
do 
{
    while (Console.ReadKey(true).Key != ConsoleKey.Escape) 
    {
    // Full program
    }       
} while (! Console.KeyAvailable);

要清除控制台,可以使用

根据您的需求,听起来您根本不需要循环:

Console.WriteLine("");
Console.WriteLine("Press any key to Continue");
if (Console.ReadKey(true).Key != ConsoleKey.Escape)
{
     Console.Clear(); // Clears the message as per your requirements

     // Full program here
}