C# Console GetCursorPosition() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Console

Definition

In C#, Console.GetCursorPosition returns the cursor’s column and row as a value tuple (int Left, int Top). It is available in .NET 5 and later.

Use it when you need to remember a position before moving the cursor, or to print status text without losing your place. Like other cursor APIs, it is console-window oriented and may throw if the console is redirected or unsupported.

This is a static member of System.Console. You call it with the type name, such as Console.GetCursorPosition(...). Console is the everyday API for reading from standard input and writing to standard output in C# console apps.

Syntax

Deconstruct the tuple into left and top coordinates.

C#
(int left, int top) = Console.GetCursorPosition();
var pos = Console.GetCursorPosition();
CallWhat it does
Console.GetCursorPosition()Returns (Left, Top) for the cursor.

Older code often used Console.CursorLeft and Console.CursorTop separately. GetCursorPosition packages both.

Library declarations
C#
public static (int Left, int Top) GetCursorPosition();

Parameters

ParameterDescription
NoneTakes no parameters.

Return Value

Return ValueDescription
(Left, Top)Column (Left) and row (Top), zero-based in the buffer.

C# Examples

Example 1 — Print the Current Cursor Position

Read Left/Top after some output.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine("Hello");
        (int left, int top) = Console.GetCursorPosition();
        Console.WriteLine("Left=" + left + " Top=" + top);
    }
}

How It Works

  1. After Hello. WriteLine moves the cursor to the next line.
  2. Typical Left 0. New line starts at column 0.
  3. Top advanced. Row increases after the first line (exact value can vary with buffer start).
  4. Tuple deconstruct. Clean syntax for both coordinates.

Example 2 — Remember Position, Write, Then Return

Save coordinates, print elsewhere, then SetCursorPosition back.

C#
using System;

class Program {
    static void Main() {
        Console.Write("Name: ");
        var mark = Console.GetCursorPosition();
        Console.WriteLine();
        Console.WriteLine("(status line)");
        Console.SetCursorPosition(mark.Left, mark.Top);
        Console.Write("Ada");
        Console.WriteLine();
    }
}

How It Works

  1. Mark after prompt. Save where the name should appear.
  2. Temporary status. Print a status on the next lines.
  3. Restore. SetCursorPosition returns to the saved spot.
  4. Sample Ada. Name is written at the original prompt position.

Example 3 — Read Position for an In-Place Counter

Combine GetCursorPosition with SetCursorPosition for a tiny counter.

C#
using System;

class Program {
    static void Main() {
        Console.Write("Count: ");
        var p = Console.GetCursorPosition();
        for (int i = 1; i <= 3; i++) {
            Console.SetCursorPosition(p.Left, p.Top);
            Console.Write(i);
        }
        Console.WriteLine();
        Console.WriteLine("Done");
    }
}

How It Works

  1. Anchor. Store the cell after the label.
  2. Overwrite. Each loop writes the new digit in the same place.
  3. Final 3. sample output shows the last value left on screen.
  4. .NET 5 API. GetCursorPosition keeps Left/Top together.

Frequently Asked Questions

It is available in .NET 5 and later.
Left is the column; Top is the row (zero-based).
Yes if the console does not support cursor queries (for example some redirected cases).
CursorLeft/CursorTop are separate properties; GetCursorPosition returns both at once.
SetCursorPosition to move back to a saved location.

Next: OpenStandardError()

Return the raw standard error Stream (optionally buffered) with System.Console.

OpenStandardError() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful