TimeZoneInfo.DisplayName 屬性

定義

取得代表時區的一般顯示名稱。

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

屬性值

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系統時區的時區顯示名稱會遵循相當標準的格式。 顯示名稱的第一個部分是時區與國際標準時間的基底位移,以 Greenwich Mean Time) 縮寫 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)  

適用於