Console::Title Property
Gets or sets the title to display in the console title bar.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System::StringThe string to be displayed in the title bar of the console. The maximum length of the title string is 24500 characters.
| Exception | Condition |
|---|---|
| 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 nullptr. |
| 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.
// 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.) */
- UIPermission
for modifying safe top-level windows and subwindows. Associated enumeration: UIPermissionWindow::SafeTopLevelWindows
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.