如何在 C# 中更改控制檯的 CursorTop?


要在 C# 中更改控制檯的 CursorTop,請使用 Console.CursorTop 屬性

舉例

讓我們看一個示例 -

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.CursorTop = 20;       Console.WriteLine("
CursorTop = "+Console.CursorTop);    } }

輸出

這將產生以下輸出 -

更新於: 14-11-2019

154 個瀏覽量

開啟您的 職業生涯

完成課程以獲得認證

開始
廣告
© . All rights reserved.