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

GregorianCalendar.CalendarType Property

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

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

public virtual GregorianCalendarTypes CalendarType { get; set; }

Property Value

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

ExceptionCondition
ArgumentOutOfRangeException

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

InvalidOperationException

In a set operation, the current instance is read-only.

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

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)

*/

.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

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft