Console.Title Eigenschaft

Definition

Ruft den auf der Konsolentitelleiste anzuzeigenden Titel ab oder legt diesen fest.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 { get; set; }
member this.Title : string with get, set
Public Shared Property Title As String

Eigenschaftswert

Die Zeichenfolge, die auf der Titelleiste der Konsole angezeigt werden soll.The string to be displayed in the title bar of the console. Die maximale Länge der Titelzeichenfolge beträgt 24500 Zeichen.The maximum length of the title string is 24500 characters.

Ausnahmen

In einem Get-Vorgang umfasst der abgerufene Titel mehr als 24500 Zeichen.In a get operation, the retrieved title is longer than 24500 characters.

In einem Set-Vorgang umfasst der angegebene Titel mehr als 24500 Zeichen.In a set operation, the specified title is longer than 24500 characters.

In einem Set-Vorgang ist der angegebene Titel null.In a set operation, the specified title is null.

E/A-FehlerAn I/O error occurred.

Der get-Vorgang wird unter einem anderen Betriebssystem als Windows aufgerufen.The get operation is invoked on an operating system other than Windows.

Beispiele

In diesem Beispiel wird die Title-Eigenschaft veranschaulicht.This example demonstrates the Title property. Das Beispiel zeigt den aktuellen Titel des Betriebssystem Fensters an, wartet auf einen Tastendruck und zeigt dann einen neuen Titel an.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.
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.)
'

Gilt für: