Calendar.Eras 属性

当在派生类中重写时,获取当前日历中的纪元列表。

**命名空间:**System.Globalization
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public MustOverride ReadOnly Property Eras As Integer()
用法
Dim instance As Calendar
Dim value As Integer()

value = instance.Eras
public abstract int[] Eras { get; }
public:
virtual property array<int>^ Eras {
    array<int>^ get () abstract;
}
/** @property */
public abstract int[] get_Eras ()
public abstract function get Eras () : int[]

属性值

表示当前日历中的纪元的整数数组。

备注

纪元按照与年代相反的顺序排序,因此,当前纪元是数组的第一个元素,而最早的纪元是数组的最后一个元素。例如,在 JapaneseCalendar 中当前纪元的值为 4,它是数组的第一个元素。

示例

下面的代码示例显示 JapaneseCalendar.Eras 中包含的值。

Imports System
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 'Main 

End Class 'SamplesJapaneseCalendar

'This code produces the following output.
'
'Eras[0] = 4
'Eras[1] = 3
'Eras[2] = 2
'Eras[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

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

*/
import System.*;
import System.Globalization.*;

public class SamplesJapaneseCalendar
{   
    public static void main(String[] args)
    {
        // Creates and initializes a JapaneseCalendar.
        JapaneseCalendar myCal =  new JapaneseCalendar();

        // Displays the values in the get_Eras() property.
        for(int i=0;i < myCal.get_Eras().length;i++) {
            Console.WriteLine("Eras[{0}] = {1}",System.Convert.ToString(i),
                System.Convert.ToString(myCal.get_Eras().get_Item(i)));
        } 
    } //main
} //SamplesJapaneseCalendar

/*
This code produces the following output.

Eras[0] = 4
Eras[1] = 3
Eras[2] = 2
Eras[3] = 1

*/

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Calendar 类
Calendar 成员
System.Globalization 命名空间
CurrentEra