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


要在 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);    } }

输出

这会产生以下输出 −

更新于: 13-11-2019

254 次查看

开启您的 职业生涯

通过完成课程获得认证

开始
广告
© . All rights reserved.