如何用 C# 更改控制台的 WindowWidth?
使用 Console.WindowWidth 属性更改控制台的 WindowWidth。
示例
现在,我们来看一个示例 −
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.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); Console.WindowWidth = 30; Console.Write("WindowWidth = "+Console.WindowWidth); } }
输出
这会产生以下输出 −
Input Encoding Scheme = System.Text.ASCIIEncoding Output Encoding Scheme = System.Text.ASCIIEncoding Cursor is Visible? False WindowWidth = 30
广告