JapaneseCalendar.Eras 屬性

定義

取得 JapaneseCalendar 中的紀元清單。Gets the list of eras in the 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 中的紀元。An array of integers that represents the eras in the JapaneseCalendar.

範例

下列範例會顯示 Eras 屬性中包含的值。The following example displays the values contained in the Eras property.

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
'

備註

日文行事曆可辨識每個天皇的統治一個紀元。The Japanese calendar recognizes one era for every emperor's reign. 這兩個最新的紀元是 Heisei 紀元,從西曆年1989開始,而 Reiwa 紀元則從西曆年2019開始。The two most recent eras are the Heisei era, beginning in the Gregorian calendar year 1989, and the Reiwa era, beginning in the Gregorian calendar year 2019. 紀元名稱通常會顯示在年份之前。The era name is typically displayed before the year. 例如,西曆年份2001是日本歷年度 Heisei 13。For example, the Gregorian calendar year 2001 is the Japanese calendar year Heisei 13. 請注意,紀元的第一年稱為「Gannen」。Note that the first year of an era is called "Gannen." 因此,西曆年份1989是日本歷年度 Heisei Gannen。Therefore, the Gregorian calendar year 1989 was the Japanese calendar year Heisei Gannen.

重要

日本曆法的紀元是以天皇的統治為基礎,因此有變更是正常的。Eras in the Japanese calendars are based on the emperor's reign and are therefore expected to change. 例如,2019 年 5 月 1 日之後,JapaneseCalendarJapaneseLunisolarCalendar 中將開始使用「令和」。For example, May 1, 2019 marked the beginning of the Reiwa era in the JapaneseCalendar and JapaneseLunisolarCalendar. 此變更對使用這些日曆的所有應用程式都有影響。Such a change of era affects all applications that use these calendars. 若要取得詳細資訊及判斷您的應用程式是否受影響,請參閱 Handling a new era in the Japanese calendar in .NET (處理 .NET 中日本日曆的新紀元)。See Handling a new era in the Japanese calendar in .NET for more information and to determine whether your applications are affected. 若要了解如何在 Windows 系統上測試您的應用程式,確保其已準備好面對紀元變更,請參閱 Prepare your application for the Japanese era change (讓應用程式準備好因應日本紀元變更)。See Prepare your application for the Japanese era change for information on testing your applications on Windows systems to ensure their readiness for the era change. 請參閱使用紀年以了解 .NET 中支援使用多種紀年的日曆,以及在處理支援多種紀年的日曆時能採用最佳做法。See Working with eras for features in .NET that support calendars with multiple eras and for best practices when working with calendars that support multiple eras.

這個類別會將數位指派給紀元,如下所示:This class assigns numbers to the eras as follows:

GetEra 值GetEra value 紀元名稱Era Name 紀元縮寫Era Abbreviation 西曆日期Gregorian Dates
55 令和 (Reiwa)令和 (Reiwa) 令和(R,r)令和 (R, r) 2019 5 月1日呈現May 1, 2019 to present
44 平成 (Heisei)平成 (Heisei) 平(H,h)平 (H, h) 1989年1月8日呈現January 8, 1989 to present
33 昭和 (Showa)昭和 (Showa) 昭(秒)昭 (S, s) 1926年12月25日至1989年1月7日December 25, 1926 to January 7, 1989
22 大正 (Taisho)大正 (Taisho) 大(T,t)大 (T, t) 1912年7月30日至12月24日,1926July 30, 1912 to December 24, 1926
11 明治 (Meiji)明治 (Meiji) 明(M,m)明 (M, m) 1912年9月 1868 8 日至7月29日September 8, 1868 to July 29, 1912

此類別會處理 Meiji 1 年9月8日的日期(西曆的1868年1月1日)。This class handles dates from September 8 in the year Meiji 1 (January 1, 1868 of the Gregorian calendar). 雖然日本行事曆已從陰曆行事曆切換到 Meiji 6 年(西曆1873)中的日光曆,但此實作為僅以陽曆為基礎。Although the Japanese calendar was switched from a lunar calendar to a solar calendar in the year Meiji 6 (1873 of the Gregorian calendar), this implementation is based on the solar calendar only.

注意

未來若要加入其他紀元,應用程式可能會遇到超過日本曆預期的五個紀元。Should additional eras be added in the future, applications may encounter more than the expected five eras for the Japanese calendar. 您的應用程式應該經過測試,以確保它們在這類事件中繼續正常執行;請參閱日文行事曆的紀元處理Your applications should be tested to ensure that they continue to work in such an event; see Era Handling for the Japanese Calendar.

適用於

另請參閱