C# Console CursorLeft

Description

Console CursorLeft gets or sets the column position of the cursor within the buffer area.

Syntax

Console.CursorLeft has the following syntax.


public static int CursorLeft { 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;//w  w  w.  ja  v a2 s  . c om

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