1

我正在 C# 控制台中开发一个用于作业的游戏。我在 ASCII 艺术中对游戏的开始做了一种介绍。我想要的是显示这段代码5秒钟,然后进入游戏。

我搜索了信息并尝试了Console.Clear()但不接受TimeSpan参数。

我不是要你做我的工作,而是寻求指导来做这件事。

我留下 ASCII 艺术的代码,壁纸取自 CM Punk “Best in the World”。

class Programa
{
    static void Main()
    {
        // BEST IN THE WORLD!!!!
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("       Z");
        Console.WriteLine("         Z=");
        Console.ResetColor();
        Console.Write("++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write("MZZ.");
        Console.ResetColor();
        Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.Write("++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write("$ZZ:.");
        Console.ResetColor();
        Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.Write("++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write(".ZZZZ:.");
        Console.ResetColor();
        Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.Write("++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write(".ZZZZZ:.");
        Console.ResetColor();
        Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.Write("++++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write(".ZZZZZZZ:.");
        Console.ResetColor();
        Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.Write("++++++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write(".ZZZZZZZZZ:.");
        Console.ResetColor();
        Console.WriteLine("++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.Write("++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write(".zZZZZZZZZZZZ:.");
        Console.ResetColor();
        Console.WriteLine("+++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("                zZZZZZZZZ:.");
        Console.WriteLine("                    zZZZZZ$ZZ:..:7ZZZZZ7$.                                     ");
        Console.WriteLine("                        zZZZZZ. .7.  .$$ZZz                                    ");
        Console.WriteLine("                           zZZZ+:  :Z     ZZ$                                  ");
        Console.WriteLine("     *            *          zZZZZz   Z  Z$Z$             *             *      ");
        Console.WriteLine("*    *    *  *    *    *    zZZZZZZZ   Z$   ZZ       *    *    *   *    *    * ");
        Console.WriteLine("  *******      *******      ZZZ:ZZ.:Z:  Z  Zz          *******       *******   ");
        Console.WriteLine("   *****        ****        ZZ+ZZZZ.  Z7Z$ZZZ:          *****         *****    ");
        Console.WriteLine("  *******      *******      $ZZZI     $Z$$$ZZZZ,       *******       *******   ");
        Console.WriteLine("*    *    *  *    *    *     ZZZZZZ   Z$   ZZ  ZZZZ:.*    *    *   *    *    * ");
        Console.WriteLine("     *            *            zIO,,     :7Z$   7ZZZZ=,   *             *      ");
        Console.WriteLine("                                   $       ZZO    7ZZZZ$+7                     ");
        Console.WriteLine("                                  OZO$.....Z~...7ZZZZI:ZZZZZ+$                 ");
        Console.WriteLine("                                    ZZO:...$ZI.,    7ZZZZ,Z                  ");
        Console.WriteLine("                                   .Z$.OI:?ZOZ,      $77ZZ                     ");
        Console.ResetColor();
        Console.Write("++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write(".ZZZZZZZ:.");
        Console.ResetColor();
        Console.WriteLine("++++++++++++++++");
        Console.Write("+++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write(".C7ZZI.");
        Console.ResetColor();
        Console.WriteLine("++++++++++++++++");
        Console.Write("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write("7ZZ:.");
        Console.ResetColor();
        Console.WriteLine("++++++++++++++");
        Console.Write("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write(".Z.");
        Console.ResetColor();
        Console.WriteLine("++++++++++++++");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.WriteLine("                              BEST IN THE WORLD");


    }
}
4

4 回答 4

2

一些选项是Thread.Sleep(5000)Task.Delay(5000)。在控制台应用程序中,您使用两者中的哪一个通常并不重要。在大多数其他情况下,如果您使用的是 .NET 4.5 或更高版本,我会推荐后者,因为新的 .Net 异步功能要好得多。

于 2013-04-19T16:18:35.200 回答
2

你可以让当前线程休眠 5 秒:

System.Threading.Thread.Sleep(5000);
于 2013-04-19T16:18:50.500 回答
2
System.Threading.Thread.Sleep(5000);

将暂停您的应用程序 5 秒钟。

于 2013-04-19T16:18:51.437 回答
2

只是Thread.Sleep用来暂停当前线程的执行一段时间。

于 2013-04-19T16:18:52.013 回答