JapaneseCalendar.Eras 屬性

定義

取得 JapaneseCalendar 中的紀元清單。

public:
 virtual property cli::array <int> ^ Eras { cli::array <int> ^ get(); };
public override int[] Eras { get; }
member this.Eras : int[]
Public Overrides ReadOnly Property Eras As Integer()

屬性值

Int32[]

整數陣列,表示 JapaneseCalendar 中的紀元。

範例

下列範例會顯示 屬性中包含的 Eras 值。

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a JapaneseCalendar.
   JapaneseCalendar^ myCal = gcnew 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->Item[0] = 4
Eras->Item[1] = 3
Eras->Item[2] = 2
Eras->Item[3] = 1

*/
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
'

備註

日曆可辨識每一個紀元的重新簽署。 最近兩個紀元是 Heisei 紀元,從西曆年 1989 開始,而 Reiwa 紀元則從西曆年 2019 開始。 紀元名稱通常會顯示在年份之前。 例如,西曆年 2001 年是日曆年份 Heisei 13。 請注意,紀元的第一年稱為 「Gannen」。 因此,西曆年 1989 是日曆年 Heisei Gannen。

重要

日本曆法的紀元是以天皇的統治為基礎,因此有變更是正常的。 例如,2019 年 5 月 1 日之後,JapaneseCalendarJapaneseLunisolarCalendar 中將開始使用「令和」。 此變更對使用這些日曆的所有應用程式都有影響。 如需詳細資訊,以及判斷您的應用程式是否受到影響,請參閱在 .net 的日文日曆中處理新的紀元。 如需在 Windows 系統上測試您的應用程式以確保其在年代的就緒狀態變更的相關資訊,請參閱準備您的應用程式以進行日本時代變更。 針對支援多個紀元日曆的 .NET 功能,以及在使用支援多個紀元的行事歷時的最佳作法,請參閱 使用紀元

此類別會將數位指派給紀元,如下所示:

GetEra 值 紀元名稱 紀元縮寫 西曆日期
5 (Reiwa) 管理與 (R、r) 2019 年 5 月 1 日至目前
4 平成 (Heisei) 平 (H、 h) 1989 年 1 月 8 日至目前
3 (Showa) (S) 1926 年 12 月 25 日到 1989 年 1 月 7 日
2 大正 (Taisho) 大 (T, t) 1912 年 7 月 30 日到 1926 年 12 月 24 日
1 (Meiji) 明 (M, m) 1868 年 9 月 8 日到 1912 年 7 月 29 日

此類別會處理 Meiji 1 年 9 月 8 日 (西曆) 1868 年 9 月 8 日日期。 雖然日曆從月曆切換為 Meiji 6 (1873 年西曆) 的月曆,但此實作僅乙太陽能曆為基礎。

注意

未來應該新增額外的紀元,應用程式可能會遇到超過日曆預期的五紀元。 您的應用程式應該經過測試,以確保它們能夠繼續在這類事件中運作;請參閱 日曆的紀元處理

適用於

另請參閱