1. <small id='pEyRa'></small><noframes id='pEyRa'>

      <i id='pEyRa'><tr id='pEyRa'><dt id='pEyRa'><q id='pEyRa'><span id='pEyRa'><b id='pEyRa'><form id='pEyRa'><ins id='pEyRa'></ins><ul id='pEyRa'></ul><sub id='pEyRa'></sub></form><legend id='pEyRa'></legend><bdo id='pEyRa'><pre id='pEyRa'><center id='pEyRa'></center></pre></bdo></b><th id='pEyRa'></th></span></q></dt></tr></i><div id='pEyRa'><tfoot id='pEyRa'></tfoot><dl id='pEyRa'><fieldset id='pEyRa'></fieldset></dl></div>

      <tfoot id='pEyRa'></tfoot><legend id='pEyRa'><style id='pEyRa'><dir id='pEyRa'><q id='pEyRa'></q></dir></style></legend>
        • <bdo id='pEyRa'></bdo><ul id='pEyRa'></ul>

        如何在 .NET 中禁止将按键打印到控制台?

        时间:2023-08-27

        <small id='ccj4e'></small><noframes id='ccj4e'>

      1. <tfoot id='ccj4e'></tfoot>
        <i id='ccj4e'><tr id='ccj4e'><dt id='ccj4e'><q id='ccj4e'><span id='ccj4e'><b id='ccj4e'><form id='ccj4e'><ins id='ccj4e'></ins><ul id='ccj4e'></ul><sub id='ccj4e'></sub></form><legend id='ccj4e'></legend><bdo id='ccj4e'><pre id='ccj4e'><center id='ccj4e'></center></pre></bdo></b><th id='ccj4e'></th></span></q></dt></tr></i><div id='ccj4e'><tfoot id='ccj4e'></tfoot><dl id='ccj4e'><fieldset id='ccj4e'></fieldset></dl></div>
      2. <legend id='ccj4e'><style id='ccj4e'><dir id='ccj4e'><q id='ccj4e'></q></dir></style></legend>

            <tbody id='ccj4e'></tbody>
            <bdo id='ccj4e'></bdo><ul id='ccj4e'></ul>

                • 本文介绍了如何在 .NET 中禁止将按键打印到控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在将一个小型 C++ 控制台游戏移植到 C#,似乎无法阻止按键被打印到控制台.

                  I'm porting a small C++ console game to C# and it seems that I can't stop key presses from being printed to the console.

                  在 C++ 中,我使用这种方法获得击键,这也抑制了击键被打印到控制台:

                  In C++ I get the keystroke with this method, which also suppress the keystrokes from being printed to the console:

                  bool Game::getInput(char *c)
                  {
                      if (_kbhit())
                      {
                          *c = _getch();
                          return true;
                      }
                      return false;
                  }
                  

                  我尝试在 C# 中做同样的事情:

                  I tried to do the equivalent in C# by doing:

                  Key = Console.ReadKey();
                  

                  但这并不能抑制字符被打印到控制台,从而导致明显的问题.关于如何解决这个问题的任何想法?

                  But this does not suppress the character from being printed to the console, causing obvious problems. Any ideas on how to remedy this?

                  推荐答案

                  你想要 Console.ReadKey(true)

                  获取用户按下的下一个字符或功能键.按下的键可选地显示在控制台窗口中.

                  Obtains the next character or function key pressed by the user. The pressed key is optionally displayed in the console window.

                  参数-称为拦截:

                  确定是否在控制台窗口中显示按下的键.true 不显示按下的键;否则,false.

                  Determines whether to display the pressed key in the console window. true to not display the pressed key; otherwise, false.

                  这篇关于如何在 .NET 中禁止将按键打印到控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Console.WriteLine 中的 {0} 代表什么? 下一篇:C#:以隐藏方式运行外部控制台程序

                  相关文章

                  最新文章

                  <i id='4l2XF'><tr id='4l2XF'><dt id='4l2XF'><q id='4l2XF'><span id='4l2XF'><b id='4l2XF'><form id='4l2XF'><ins id='4l2XF'></ins><ul id='4l2XF'></ul><sub id='4l2XF'></sub></form><legend id='4l2XF'></legend><bdo id='4l2XF'><pre id='4l2XF'><center id='4l2XF'></center></pre></bdo></b><th id='4l2XF'></th></span></q></dt></tr></i><div id='4l2XF'><tfoot id='4l2XF'></tfoot><dl id='4l2XF'><fieldset id='4l2XF'></fieldset></dl></div>
                    <bdo id='4l2XF'></bdo><ul id='4l2XF'></ul>

                  <small id='4l2XF'></small><noframes id='4l2XF'>

                  <legend id='4l2XF'><style id='4l2XF'><dir id='4l2XF'><q id='4l2XF'></q></dir></style></legend>

                  <tfoot id='4l2XF'></tfoot>