JapaneseCalendar.Eras JapaneseCalendar.Eras JapaneseCalendar.Eras JapaneseCalendar.Eras Property

定义

获取 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 'SamplesJapaneseCalendar

'This code produces the following output.
'
'Eras[0] = 4
'Eras[1] = 3
'Eras[2] = 2
'Eras[3] = 1
'

注解

日本历可识别每个高层的 reign 的一个纪元。The Japanese calendar recognizes one era for every emperor's reign. 最新的两个纪元是 Heisei 纪元, 从公历年1989开始, 以公历年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 系统上测试应用程序以确保针对元号更改的准备情况信息。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) 5月1日, 2019May 1, 2019 to present
44 平成 (Heisei)平成 (Heisei) 平 (H, h)平 (H, h) 1989年1月8日January 8, 1989 to present
33 昭和 (Showa)昭和 (Showa) 昭 (S, s)昭 (S, s) 12月25日, 1926 到1月7日, 1989December 25, 1926 to January 7, 1989
22 大正 (Taisho)大正 (Taisho) 大 (T, t)大 (T, t) 1912年7月30日, 1926July 30, 1912 to December 24, 1926
11 明治 (Meiji)明治 (Meiji) 明 (M, m)明 (M, m) 9月8日1868到7月29日, 1912September 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. 应该对应用程序进行测试, 以确保它们在此类事件中继续工作;请参阅日本历的 Era 处理Your applications should be tested to ensure that they continue to work in such an event; see Era Handling for the Japanese Calendar.

适用于

另请参阅