Search code examples
c#visual-studio-2013consolecursor-position

How to check if the cursor is on blank console space(C#)


I want to check if the cursor is on a text/character or on blank console area. Is there any way to do this in the console Application in C#?enter image description here

Just want to know if the yellow cursor (in my case) is on one of the @S or on a blank console space.


Solution

  • What works for me is:

    if (Console.CursorLeft == checkedXPosition && Console.CursorTop == checkedYPosition)
    {
      // Do something
    }