.NET Framework Class Library
CultureInfoOptionalCalendars Property

Gets the list of calendars that can be used by the culture.

Namespace:   System.Globalization
Assemblies:   mscorlib (in mscorlib.dll)
  System.Globalization (in System.Globalization.dll)
Syntax
Public Overridable ReadOnly Property OptionalCalendars As [%$TOPIC/1kds87wa_en-us_VS_110_1_0_0_0_0%]()
public virtual [%$TOPIC/1kds87wa_en-us_VS_110_1_0_1_0_0%][] OptionalCalendars { get; }
public:
virtual property array<[%$TOPIC/1kds87wa_en-us_VS_110_1_0_2_0_0%]^>^ OptionalCalendars {
	array<[%$TOPIC/1kds87wa_en-us_VS_110_1_0_2_0_1%]^>^ get ();
}
abstract OptionalCalendars : [%$TOPIC/1kds87wa_en-us_VS_110_1_0_3_0_0%][] with get 
override OptionalCalendars : [%$TOPIC/1kds87wa_en-us_VS_110_1_0_3_0_1%][] with get
function get OptionalCalendars () : [%$TOPIC/1kds87wa_en-us_VS_110_1_0_4_0_0%][]

Property Value

Type: System.GlobalizationCalendar
An array of type Calendar that represents the calendars that can be used by the culture represented by the current CultureInfo.
Remarks

Your application changes the calendar used by the current CultureInfo by setting the Calendar property of DateTimeFormat, which is an instance of the DateTimeFormatInfo class. The new calendar must be one of the calendars listed in OptionalCalendars. DateTimeFormat also includes other properties that customize the date and time formatting associated with that Calendar.

Examples

The following code example demonstrates how to determine the GregorianCalendar versions supported by the culture.

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)

*/
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8