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