当前位置: 首页>>代码示例>>C#>>正文


C# Console.CursorVisible属性代码示例

本文整理汇总了C#中System.Console.CursorVisible属性的典型用法代码示例。如果您正苦于以下问题:C# Console.CursorVisible属性的具体用法?C# Console.CursorVisible怎么用?C# Console.CursorVisible使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Console的用法示例。


在下文中一共展示了Console.CursorVisible属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

// This example demonstrates the Console.CursorVisible property.

using System;

class Sample 
{
    public static void Main() 
    {
    string m1 = "\nThe cursor is {0}.\nType any text then press Enter. " +
                "Type '+' in the first column to show \n" +
                "the cursor, '-' to hide the cursor, " +
                "or lowercase 'x' to quit:";
    string s;
    bool saveCursorVisibile;
    int  saveCursorSize;
//
    Console.CursorVisible = true; // Initialize the cursor to visible.
    saveCursorVisibile = Console.CursorVisible;
    saveCursorSize  = Console.CursorSize;
    Console.CursorSize = 100;     // Emphasize the cursor.

    while(true) 
        {
        Console.WriteLine(m1, 
                         ((Console.CursorVisible == true) ? 
                           "VISIBLE" : "HIDDEN"));
        s = Console.ReadLine();
        if (String.IsNullOrEmpty(s) == false) 
            if (s[0] == '+')
                Console.CursorVisible = true;
            else if (s[0] == '-')
                Console.CursorVisible = false;
            else if (s[0] == 'x')
                break;
        }
    Console.CursorVisible = saveCursorVisibile;
    Console.CursorSize    = saveCursorSize;
    }
}
/*
This example produces the following results. Note that these results
cannot depict cursor visibility. You must run the example to see the 
cursor behavior:

The cursor is VISIBLE.
Type any text then press Enter. Type '+' in the first column to show
the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
The quick brown fox

The cursor is VISIBLE.
Type any text then press Enter. Type '+' in the first column to show
the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
-

The cursor is HIDDEN.
Type any text then press Enter. Type '+' in the first column to show
the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
jumps over

The cursor is HIDDEN.
Type any text then press Enter. Type '+' in the first column to show
the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
+

The cursor is VISIBLE.
Type any text then press Enter. Type '+' in the first column to show
the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
the lazy dog.

The cursor is VISIBLE.
Type any text then press Enter. Type '+' in the first column to show
the cursor, '-' to hide the cursor, or lowercase 'x' to quit:
x

*/
开发者ID:.NET开发者,项目名称:System,代码行数:75,代码来源:Console.CursorVisible

示例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();

  }
}
开发者ID:C#程序员,项目名称:System,代码行数:23,代码来源:Console.CursorVisible


注:本文中的System.Console.CursorVisible属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。