Calendar.Eras 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當在派生類別中覆寫時,會獲得當前日曆中的時代列表。
public:
abstract property cli::array <int> ^ Eras { cli::array <int> ^ get(); };
public abstract int[] Eras { get; }
member this.Eras : int[]
Public MustOverride ReadOnly Property Eras As Integer()
屬性值
一個整數陣列,代表當前曆法中的各個時代。
範例
以下範例展示了平成時代(1989-2019)為當前時代的數值 JapaneseCalendar.Eras 。
using System;
using System.Globalization;
public class SamplesJapaneseCalendar {
public static void Main() {
// Creates and initializes a JapaneseCalendar.
JapaneseCalendar myCal = new JapaneseCalendar();
// Displays the values in the Eras property.
for ( int i = 0; i < myCal.Eras.Length; i++ ) {
Console.WriteLine( "Eras[{0}] = {1}", i, myCal.Eras[i] );
}
}
}
/*
This code produces the following output.
Eras[0] = 4
Eras[1] = 3
Eras[2] = 2
Eras[3] = 1
*/
Imports System.Globalization
Public Class SamplesJapaneseCalendar
Public Shared Sub Main()
' Creates and initializes a JapaneseCalendar.
Dim myCal As New JapaneseCalendar()
' Displays the values in the Eras property.
Dim i As Integer
For i = 0 To myCal.Eras.Length - 1
Console.WriteLine("Eras[{0}] = {1}", i, myCal.Eras(i))
Next i
End Sub
End Class
'This code produces the following output.
'
'Eras[0] = 4
'Eras[1] = 3
'Eras[2] = 2
'Eras[3] = 1
'
備註
時代按時間順序倒序排列,當前紀元為陣列的第一個元素,最古老的紀元為陣列的最後一個元素。 例如,當前 JapaneseCalendar 時代的值為 4,即陣列的第一個元素。 只有 和 JapaneseCalendarJapaneseLunisolarCalendar 職業支援多個時代。
Important
日本日曆中的紀元基於皇帝的統治,因此預計將改變。 例如,2019 年 5 月 1 日在 JapaneseCalendar 和 JapaneseLunisolarCalendar中標示了 Reiwa 時代的開頭。 這種時代變更會影響使用這些行事曆的所有應用程式。 如需詳細資訊,以及判斷您的應用程式是否受到影響,請參閱 處理 .NET 中日曆中的新紀元。 如需在 Windows 系統上測試應用程式,以確保其準備迎接時代變更的相關信息,請參閱 準備您的應用程式以取得日本年號變更。 如需 .NET 中支援具有多個紀元的行事曆功能,以及使用支援多個紀元的行事曆時的最佳作法,請參閱 使用紀元。
JapaneseCalendar這些JapaneseLunisolarCalendar職業支援多個時代。 大多數曆法實作則支援單一時代。