Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Console.Title Property

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

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

'Declaration
Public Shared Property Title As 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 Nothing.

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. 
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.) 
'

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Show:
© 2015 Microsoft