如何在 C# 中更改控制台光标的可见性
要更改光标的可见性,请使用 Console.CursorVisible 属性。
示例
我们来看一个示例 -
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Demo { public static void Main (string[] args) { Console.BackgroundColor = ConsoleColor. Black; Console.WriteLine("Background color changed = "+Console.BackgroundColor); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("
Foreground color changed = "+Console.ForegroundColor); Console.InputEncoding = Encoding.ASCII; Console.WriteLine("Input Encoding Scheme = "+Console.InputEncoding); Console.OutputEncoding = Encoding.ASCII; Console.WriteLine("Output Encoding Scheme = "+Console.OutputEncoding); Console.CursorVisible = false; Console.Write("
Cursor is Visible? "+ Console.CursorVisible); } }
输出
这将产生以下输出 -
广告