Freigeben über


CultureInfo.OptionalCalendars-Eigenschaft

Ruft die Liste der Kalender ab, die von dieser Kultur verwendet werden können.

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overridable ReadOnly Property OptionalCalendars As Calendar()
'Usage
Dim instance As CultureInfo
Dim value As Calendar()

value = instance.OptionalCalendars
public virtual Calendar[] OptionalCalendars { get; }
public:
virtual property array<Calendar^>^ OptionalCalendars {
    array<Calendar^>^ get ();
}
/** @property */
public Calendar[] get_OptionalCalendars ()
public function get OptionalCalendars () : Calendar[]

Eigenschaftenwert

Ein Array vom Typ Calendar, das die Kalender darstellt, die von der Kultur verwendet werden können, die von der aktuellen CultureInfo dargestellt werden.

Hinweise

Sie können den von der aktuellen CultureInfo verwendeten Kalender ändern, indem Sie die Calendar-Eigenschaft auf DateTimeFormat festlegen. Hierbei handelt es sich um eine Instanz der DateTimeFormatInfo-Klasse. Der neue Kalender muss einer der in OptionalCalendars aufgelisteten Kalender sein. DateTimeFormat enthält darüber hinaus andere Eigenschaften, die die Datums- und Uhrzeitformatierung anpassen, die mit diesem Calendar verbunden ist.

Beispiel

In folgendem Codebeispiel wird veranschaulicht, wie die von der Kultur unterstützten Versionen des gregorianischen Kalenders bestimmt werden.

Imports System
Imports System.Globalization

Public Class SamplesCultureInfo

   Public Shared Sub Main()

      ' Gets the calendars supported by the ar-SA culture.
      Dim myOptCals As Calendar() = New CultureInfo("ar-SA").OptionalCalendars

      ' Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
      Console.WriteLine("The ar-SA culture supports the following calendars:")
      Dim cal As Calendar
      For Each cal In  myOptCals
         If cal.GetType() Is GetType(GregorianCalendar)  Then
            Dim myGreCal As GregorianCalendar = CType(cal, GregorianCalendar)
            Dim calType As GregorianCalendarTypes = myGreCal.CalendarType
            Console.WriteLine("   {0} ({1})", cal, calType)
         Else
            Console.WriteLine("   {0}", cal)
         End If
      Next cal

   End Sub 'Main 

End Class 'SamplesCultureInfo


'This code produces the following output.
'
'The ar-SA culture supports the following calendars:
'   System.Globalization.HijriCalendar
'   System.Globalization.GregorianCalendar (USEnglish)
'   System.Globalization.GregorianCalendar (MiddleEastFrench)
'   System.Globalization.GregorianCalendar (Arabic)
'   System.Globalization.GregorianCalendar (Localized)
'   System.Globalization.GregorianCalendar (TransliteratedFrench)
using System;
using System.Globalization;


public class SamplesCultureInfo  {

   public static void Main()  {

      // Gets the calendars supported by the ar-SA culture.
      Calendar[] myOptCals = new CultureInfo("ar-SA").OptionalCalendars;

      // Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
      Console.WriteLine( "The ar-SA culture supports the following calendars:" );
      foreach ( Calendar cal in myOptCals )  {
         if ( cal.GetType() == typeof( GregorianCalendar ) )  {
            GregorianCalendar myGreCal = (GregorianCalendar) cal;
            GregorianCalendarTypes calType = myGreCal.CalendarType;
            Console.WriteLine( "   {0} ({1})", cal, calType );
         }
         else  {
            Console.WriteLine( "   {0}", cal );
         }
      }

   }

}

/*
This code produces the following output.

The ar-SA culture supports the following calendars:
   System.Globalization.HijriCalendar
   System.Globalization.GregorianCalendar (USEnglish)
   System.Globalization.GregorianCalendar (MiddleEastFrench)
   System.Globalization.GregorianCalendar (Arabic)
   System.Globalization.GregorianCalendar (Localized)
   System.Globalization.GregorianCalendar (TransliteratedFrench)

*/
using namespace System;
using namespace System::Globalization;
using namespace System::Collections;
int main()
{
   
   // Calendar* myOptCals[] = new CultureInfo(S"ar-SA") -> OptionalCalendars;
   CultureInfo^ MyCI = gcnew CultureInfo( "ar-SA" );
   array<Calendar^>^myOptCals = MyCI->OptionalCalendars;
   
   // Checks which ones are GregorianCalendar then determines the GregorianCalendar version.
   Console::WriteLine( "The ar-SA culture supports the following calendars:" );
   IEnumerator^ myEnum = myOptCals->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Calendar^ cal = safe_cast<Calendar^>(myEnum->Current);
      if ( cal->GetType() == GregorianCalendar::typeid )
      {
         GregorianCalendar^ myGreCal = dynamic_cast<GregorianCalendar^>(cal);
         GregorianCalendarTypes calType = myGreCal->CalendarType;
         Console::WriteLine( " {0} ( {1})", cal, calType );
      }
      else
            Console::WriteLine( " {0}", cal );
   }
}

/*
This code produces the following output.

The ar-SA culture supports the following calendars:
 System.Globalization.HijriCalendar
 System.Globalization.GregorianCalendar ( USEnglish)
 System.Globalization.GregorianCalendar ( MiddleEastFrench)
 System.Globalization.GregorianCalendar ( Arabic)
 System.Globalization.GregorianCalendar ( Localized)
 System.Globalization.GregorianCalendar ( TransliteratedFrench)

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

public class SamplesCultureInfo
{
    public static void main(String[] args)
    {
        // Gets the calendars supported by the ar-SA culture.
        Calendar myOptCals[] = (new CultureInfo("ar-SA")).
            get_OptionalCalendars();

        // Checks which ones are GregorianCalendar then determines the 
        // GregorianCalendar version.
        Console.WriteLine
            ("The ar-SA culture supports the following calendars:");
        
        for (int iCtr = 0; iCtr < myOptCals.length; iCtr++) {
            Calendar cal = myOptCals[iCtr];
            if (cal.GetType() == GregorianCalendar.class.ToType()) {
                GregorianCalendar myGreCal = ((GregorianCalendar)(cal));
                GregorianCalendarTypes calType = myGreCal.get_CalendarType();
                Console.WriteLine("   {0} ({1})", cal, calType);
            }
            else {
                Console.WriteLine("   {0}", cal);
            }
        }
    } //main 
} //SamplesCultureInfo

/*
This code produces the following output.

The ar-SA culture supports the following calendars:
   System.Globalization.HijriCalendar
   System.Globalization.GregorianCalendar (USEnglish)
   System.Globalization.GregorianCalendar (MiddleEastFrench)
   System.Globalization.GregorianCalendar (Arabic)
   System.Globalization.GregorianCalendar (Localized)
   System.Globalization.GregorianCalendar (TransliteratedFrench)
*/

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

CultureInfo-Klasse
CultureInfo-Member
System.Globalization-Namespace
Calendar-Klasse
CultureInfo.DateTimeFormat-Eigenschaft
DateTimeFormatInfo