How to change the CursorSize of the Console in C#?

The Console.CursorSize property in C# allows you to change the size of the cursor in the console window. The cursor size is specified as a percentage of the character cell height, ranging from 1 to 100.

Syntax

Following is the syntax for setting the cursor size −

Console.CursorSize = value;

Parameters

  • value ? An integer between 1 and 100, representing the cursor size as a percentage of the character cell height.

Using Console.CursorSize Property

The cursor size can be set to different values to make it more or less visible. A smaller value creates a thinner cursor, while a larger value creates a thicker cursor −

Example 1: Setting Different Cursor Sizes

using System;
using System.Threading;

class Demo {
    public static void Main(string[] args) {
        Console.WriteLine("Demonstrating different cursor sizes:");
        
        Console.WriteLine("\nCursor size 1 (thinnest):");
        Console.CursorSize = 1;
        Console.WriteLine("Current cursor size: " + Console.CursorSize);
        Thread.Sleep(1000);
        
        Console.WriteLine("\nCursor size 50 (medium):");
        Console.CursorSize = 50;
        Console.WriteLine("Current cursor size: " + Console.CursorSize);
        Thread.Sleep(1000);
        
        Console.WriteLine("\nCursor size 100 (thickest):");
        Console.CursorSize = 100;
        Console.WriteLine("Current cursor size: " + Console.CursorSize);
    }
}

The output of the above code is −

Demonstrating different cursor sizes:

Cursor size 1 (thinnest):
Current cursor size: 1

Cursor size 50 (medium):
Current cursor size: 50

Cursor size 100 (thickest):
Current cursor size: 100

Example 2: Combining Cursor Size with Colors

using System;

class Demo {
    public static void Main(string[] args) {
        Console.BackgroundColor = ConsoleColor.Blue;
        Console.WriteLine("Background color changed = " + Console.BackgroundColor);
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine("\nForeground color changed = " + Console.ForegroundColor);
        Console.CursorSize = 25;
        Console.WriteLine("\nCursor size set to: " + Console.CursorSize + "%");
        Console.ResetColor();
    }
}

The output of the above code is −

Background color changed = Blue

Foreground color changed = Yellow

Cursor size set to: 25%

Key Points

  • Valid range for Console.CursorSize is 1 to 100.

  • The value represents a percentage of the character cell height.

  • A value of 1 creates the thinnest possible cursor.

  • A value of 100 creates a cursor that fills the entire character cell height.

  • Setting an invalid value (outside 1-100 range) will throw an ArgumentOutOfRangeException.

Conclusion

The Console.CursorSize property provides a simple way to customize the appearance of the console cursor. By setting values between 1 and 100, you can control the cursor thickness to improve visibility or match your application's visual style.

Updated on: 2026-03-17T07:04:36+05:30

300 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements