Console.Title Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the title to display in the console title bar.
public:
static property System::String ^ Title { System::String ^ get(); void set(System::String ^ value); };
public static string Title { [System.Runtime.Versioning.SupportedOSPlatform("windows")] get; [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] set; }
public static string Title { [System.Runtime.Versioning.SupportedOSPlatform("windows")] get; [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] [System.Runtime.Versioning.UnsupportedOSPlatform("android")] [System.Runtime.Versioning.UnsupportedOSPlatform("ios")] [System.Runtime.Versioning.UnsupportedOSPlatform("tvos")] set; }
public static string Title { get; set; }
[<get: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
static member Title : string with get, set
[<get: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<set: System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member Title : string with get, set
static member Title : string with get, set
Public Shared Property Title As String
The string to be displayed in the title bar of the console. The maximum length of the title string is 24500 characters.
- Attributes
In a get operation, the retrieved title is longer than 24500 characters.
In a set operation, the specified title is longer than 24500 characters.
In a set operation, the specified title is null
.
An I/O error occurred.
The get operation is invoked on an operating system other than Windows.
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.)
*/
// 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.
open System
printfn $"The current console title is: \"{Console.Title}\""
printfn " (Press any key to change the console title.)"
Console.ReadKey true |> ignore
Console.Title <- "The title has changed!"
printfn $"Note that the new console title is \"{Console.Title}\"\n (Press any key to quit.)"
Console.ReadKey true |> ignore
// 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.
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
End Class
'
'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.)
'
Produto | Versões |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.3, 1.4, 1.6, 2.0, 2.1 |
Comentários do .NET
O .NET é um projeto código aberto. Selecione um link para fornecer comentários: