Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
System Namespace
Console Class
 Title Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Console..::.Title Property

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

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
Public Shared Property Title As String
Visual Basic (Usage)
Dim value As String

value = Console.Title

Console.Title = value
C#
public static string Title { get; set; }
Visual C++
public:
static property String^ Title {
    String^ get ();
    void set (String^ value);
}
JScript
public static function get Title () : String
public static function set Title (value : String)

Property Value

Type: System..::.String
The string to be displayed in the title bar of the console. The maximum length of the title string is 24500 characters.
ExceptionCondition
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 nullNothingnullptra null reference (Nothing in Visual Basic).

IOException

An I/O error occurred.

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.

Visual Basic
' This example demonstrates the Console.Title property.
Imports System
Imports Microsoft.VisualBasic

Class Sample
   Public Shared Sub 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}""" & vbCrLf & _
                        "  (Press any key to quit.)", Console.Title)
      Console.ReadKey(True)
   End Sub 'Main
End Class '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.)
'
C#
// 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.)

*/
Visual C++
// This example demonstrates the Console.Title property.
using namespace System;
int 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.)

*/

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker