Calendar.Eras 屬性

定義

當在衍生類別中覆寫時,取得目前曆法中的紀元清單。

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()

屬性值

Int32[]

整數陣列,表示目前曆法中的紀元。

範例

下列範例會顯示Heisei紀元 (1989-2019年) 為目前紀元時所包含的 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
'

備註

紀元是以反向時間順序,目前紀元做為陣列的第一個專案,而最舊的紀元則為陣列的最後一個專案。 例如,中 JapaneseCalendar 目前紀元的值是 4,這是陣列的第一個專案。 JapaneseCalendar只有和 JapaneseLunisolarCalendar 類別支援多個紀元。

重要

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

JapaneseCalendarJapaneseLunisolarCalendar 類別支援多個紀元。 另一方面,大部分的行事歷實作都支援單一紀元。

適用於

另請參閱