GregorianCalendar.CalendarType Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the GregorianCalendarTypes value that denotes the language version of the current GregorianCalendar.

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

Syntax

'Declaration
Public Overridable Property CalendarType As GregorianCalendarTypes
public virtual GregorianCalendarTypes CalendarType { get; set; }

Property Value

Type: System.Globalization.GregorianCalendarTypes
A GregorianCalendarTypes value that denotes the language version of the current GregorianCalendar.

Exceptions

Exception Condition
ArgumentOutOfRangeException

The value assigned in a set operation is not a member of the GregorianCalendarTypes enumeration.

Examples

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

Imports System.Globalization

Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

      ' 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.
      outputBlock.Text &= "The ar-SA culture supports the following calendars:" & vbCrLf
      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
            outputBlock.Text += String.Format("   {0} ({1})", cal, calType) & vbCrLf
         Else
            outputBlock.Text += String.Format("   {0}", cal) & vbCrLf
         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 Example
{

   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {

      // 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.
      outputBlock.Text += "The ar-SA culture supports the following calendars:" + "\n";
      foreach (Calendar cal in myOptCals)
      {
         if (cal.GetType() == typeof(GregorianCalendar))
         {
            GregorianCalendar myGreCal = (GregorianCalendar)cal;
            GregorianCalendarTypes calType = myGreCal.CalendarType;
            outputBlock.Text += String.Format("   {0} ({1})", cal, calType) + "\n";
         }
         else
         {
            outputBlock.Text += String.Format("   {0}", cal) + "\n";
         }
      }

   }

}

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

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.