【问题标题】:Is it possible to pin a text on the top of the console c# [duplicate]是否可以在控制台顶部固定文本 c# [重复]
【发布时间】:2017-09-05 04:20:59
【问题描述】:

您好,我想在 c# 中的控制台顶部添加一个文本,上面写着(STATS: health="" Coins="",就像一个状态栏),它必须被固定(我没有不知道我是否使用了正确的动词)。我想对切换菜单做同样的事情(总是看到带有选项的菜单)。

谢谢。

【问题讨论】:

  • 您可以命名控制台窗口,但您可以编写自己的显示以允许这样做

标签: c# text interface append progress-bar


【解决方案1】:

您不能在 Windows Console Application 中固定任何内容。


我认为您尝试实现的目标是每次都清除控制台并重绘屏幕。

一个例子:

class Program
{
    static void Main(string[] args)
    {
        int counter = 0;
        while (true)
        {
            counter++;
            DrawScreen(counter); 
            Console.ReadKey();
        }
    }

    static void DrawScreen(int turn)
    {
        // Clear Console
        Console.Clear();
        // Draw Statusbar again on the 'top'
        Console.WriteLine("Current Turn: {0}", turn);

        // Draw additional stuff
    }
}

【讨论】:

  • 如何每次都清空控制台?顺便谢谢 C:
  • @Varox 在更新中添加simple turn example
猜你喜欢
  • 2014-01-11
  • 2016-12-13
  • 2020-05-26
  • 2013-03-30
  • 2012-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多