如何用 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.