Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Console.Title Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the title to display in the console title bar.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static string Title { get; set; }
/** @property */
public static String get_Title ()

/** @property */
public static void set_Title (String value)

public static function get Title () : String

public static function set Title (value : String)

Property Value

The string to be displayed in the title bar of the console. The maximum length of the title string is 24500 characters.

Exception typeCondition

InvalidOperationException

In a get operation, the retrieved title is longer than 24500 characters.

ArgumentOutOfRangeException

In a set operation, the specified title is longer than 24500 characters.

ArgumentNullException

In a set operation, the specified title is a null reference (Nothing in Visual Basic).

IOException

An I/O error occurred.

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition Platform Note: The maximum length of the title string is 127 ANSI characters. Unicode characters are not supported.

This example demonstrates the Title property. The example displays the current title of the operating system window, waits for a key press, then displays a new title.

// This example demonstrates the Console.Title property.
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine("The current console title is: \"{0}\"",
                      Console.Title);
    Console.WriteLine("  (Press any key to change the console title.)");
    Console.ReadKey(true);
    Console.Title = "The title has changed!";
    Console.WriteLine("Note that the new console title is \"{0}\"\n" +
                      "  (Press any key to quit.)", Console.Title);
    Console.ReadKey(true);
    }
}
/*
This example produces the following results:

>myTitle
The current console title is: "Command Prompt - myTitle"
  (Press any key to change the console title.)
Note that the new console title is "The title has changed!"
  (Press any key to quit.)

*/

// This example demonstrates the Console.Title property.
import System.*;

class Sample
{
    public static void main(String[] args)
    {
        Console.WriteLine("The current console title is: \"{0}\"",
            Console.get_Title());
        Console.WriteLine("  (Press any key to change the console title.)");
        Console.ReadKey(true);
        Console.set_Title("The title has changed!");
        Console.WriteLine("Note that the new console title is \"{0}\"\n" 
            + "  (Press any key to quit.)", Console.get_Title());
        Console.ReadKey(true);
    } //main
} //Sample
/*
This example produces the following results:

>myTitle
The current console title is: "Command Prompt - myTitle"
  (Press any key to change the console title.)
Note that the new console title is "The title has changed!"
  (Press any key to quit.)

*/

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft