本文整理汇总了C#中System.Console.CursorSize属性的典型用法代码示例。如果您正苦于以下问题:C# Console.CursorSize属性的具体用法?C# Console.CursorSize怎么用?C# Console.CursorSize使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Console
的用法示例。
在下文中一共展示了Console.CursorSize属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
// This example demonstrates the Console.CursorSize property.
using System;
class Sample
{
public static void Main()
{
string m0 = "This example increments the cursor size from 1% to 100%:\n";
string m1 = "Cursor size = {0}%. (Press any key to continue...)";
int[] sizes = {1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
int saveCursorSize;
//
saveCursorSize = Console.CursorSize;
Console.WriteLine(m0);
foreach (int size in sizes)
{
Console.CursorSize = size;
Console.WriteLine(m1, size);
Console.ReadKey();
}
Console.CursorSize = saveCursorSize;
}
}
输出:
This example increments the cursor size from 1% to 100%: Cursor size = 1%. (Press any key to continue...) Cursor size = 10%. (Press any key to continue...) Cursor size = 20%. (Press any key to continue...) Cursor size = 30%. (Press any key to continue...) Cursor size = 40%. (Press any key to continue...) Cursor size = 50%. (Press any key to continue...) Cursor size = 60%. (Press any key to continue...) Cursor size = 70%. (Press any key to continue...) Cursor size = 80%. (Press any key to continue...) Cursor size = 90%. (Press any key to continue...) Cursor size = 100%. (Press any key to continue...)
示例2: Main
//引入命名空间
using System;
public class Test{
static void Main(string[] args){
// Change the Console appearance and redisplay.
Console.Title = "Resized Console";
Console.ResetColor();
Console.Clear();
Console.SetWindowSize(100, 50);
Console.BufferHeight = 500;
Console.BufferWidth = 100;
Console.CursorLeft = 20;
Console.CursorSize = 50;
Console.CursorTop = 20;
Console.CursorVisible = false;
Console.WriteLine("Main method complete. Press Enter.");
Console.ReadLine();
}
}