Differences between SetCursorPosition and CursorTop, CursorLeft in C #

2

I have a question with the following example, I do not understand what exactly CursorTop and CursorLeft do not do SetCursorPosition .

using System;

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);
    }
}
    
asked by Shiki 25.07.2017 в 01:51
source

1 answer

1

In this example CursorTop and CursorLeft is used to set the initial values of the attributes origRow and origCol for later with SetCursorPosition keep changing the position of the cursor based on the initial values (of origRow and origCol ) plus the values of the arguments x and y .

    
answered by 25.07.2017 / 02:50
source