Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CultureInfo.OptionalCalendars 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)

'Declaration
Public Overridable ReadOnly Property OptionalCalendars As Calendar()

Property Value

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

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.

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)

.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
Show:
© 2015 Microsoft