語言

TimeZoneInfo.DisplayName 屬性

定義

會得到代表時區的通用顯示名稱。

public:
 property System::String ^ DisplayName { System::String ^ get(); };
public string DisplayName { get; }
member this.DisplayName : string
Public ReadOnly Property DisplayName As String

屬性值

時區的通用顯示名稱。

範例

以下範例會 TimeZoneInfo 取得一個代表當地時區的物件,並輸出其顯示名稱、標準時間名稱及夏令時間名稱。 輸出顯示為美國太平洋標準時區的系統。

using System;

public class Example
{
   public static void Main()
   {
      TimeZoneInfo localZone = TimeZoneInfo.Local;
      Console.WriteLine("Local Time Zone ID: {0}", localZone.Id);
      Console.WriteLine("   Display Name is: {0}.", localZone.DisplayName);
      Console.WriteLine("   Standard name is: {0}.", localZone.StandardName);
      Console.WriteLine("   Daylight saving name is: {0}.", localZone.DaylightName); 
   }
}
// The example displays output like the following:
//     Local Time Zone ID: Pacific Standard Time
//        Display Name is: (UTC-08:00) Pacific Time (US & Canada).
//        Standard name is: Pacific Standard Time.
//        Daylight saving name is: Pacific Daylight Time.
open System

let localZone = TimeZoneInfo.Local
printfn $"Local Time Zone ID: {localZone.Id}"
printfn $"   Display Name is: {localZone.DisplayName}."
printfn $"   Standard name is: {localZone.StandardName}."
printfn $"   Daylight saving name is: {localZone.DaylightName}."
// The example displays output like the following:
//     Local Time Zone ID: Pacific Standard Time
//        Display Name is: (UTC-08:00) Pacific Time (US & Canada).
//        Standard name is: Pacific Standard Time.
//        Daylight saving name is: Pacific Daylight Time.
Module Example
   Public Sub Main()
      Dim localZone As TimeZoneInfo = TimeZoneInfo.Local
      Console.WriteLine("Local Time Zone ID: {0}", localZone.Id)
      Console.WriteLine("   Display Name is: {0}.", localZone.DisplayName)
      Console.WriteLine("   Standard name is: {0}.", localZone.StandardName)
      Console.WriteLine("   Daylight saving name is: {0}.", localZone.DaylightName) 
   End Sub
End Module
' The example displays output like the following:
'     Local Time Zone ID: Pacific Standard Time
'        Display Name is: (UTC-08:00) Pacific Time (US & Canada).
'        Standard name is: Pacific Standard Time.
'        Daylight saving name is: Pacific Daylight Time.

備註

顯示名稱會根據隨 Windows 作業系統安裝的文化而在地化。

Windows 系統時區的顯示名稱遵循相當標準的格式。 顯示名稱的第一部分是該時區與協調世界時的基準偏移,括號內以縮寫 GMT(格林威治標準時間)表示。 對於協調世界時,GMT縮寫(無偏移)會用括號內標示。 接著是一串字串,標示時區或該時區內的一個或多個城市、地區或國家。 例如:

(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London
(GMT+02:00) Athens, Beirut, Istanbul, Minsk
(GMT-02:00) Mid-Atlantic
(GMT-07:00) Mountain Time (US & Canada)

適用於