C# Console CursorTop

Description

Console CursorTop gets or sets the row position of the cursor within the buffer area.

Syntax

Console.CursorTop has the following syntax.


public static int CursorTop { get; set; }

Example

Gets or sets the column position of the cursor within the buffer area. This example demonstrates the CursorLeft and CursorTop properties , and the SetCursorPosition and Clear methods.


using System;//from w w w.  j a v a  2  s . com

class Sample 
{
    protected static int origRow;
    protected static int origCol;

    protected static void WriteAt(string s, int x, int y)
    {
        try{
            Console.SetCursorPosition(origCol+x, origRow+y);
            Console.Write(s);
        }catch (ArgumentOutOfRangeException e){
            Console.Clear();
            Console.WriteLine(e.Message);
        }
    }

    public static void Main() 
    {
        Console.Clear();
        origRow = Console.CursorTop;
        origCol = Console.CursorLeft;
    
        WriteAt("+", 0, 1);
    }
}




















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version