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);
}
}