如何在 C# 中更改控制台的 CursorLeft?

csharpserver side programmingprogramming更新于 2025/5/25 13:07:17

要在 C# 中更改控制台的 CursorLeft,请使用 Console.CursorLeft 属性。

示例

让我们看一个例子 −

using System;
class Demo {
   public static void Main (string[] args) {
      Console.BackgroundColor = ConsoleColor.Blue;
      Console.WriteLine("Background color changed = "+Console.BackgroundColor);
      Console.ForegroundColor = ConsoleColor.Yellow;
      Console.WriteLine("
Foreground color changed = "+Console.ForegroundColor);       Console.CursorLeft = 30;       Console.Write("CursorLeft position: "+Console.CursorLeft);    } }

输出

这将产生以下输出 −


相关文章