CultureInfo.OptionalCalendars プロパティ

定義

カルチャで使用できる暦の一覧を取得します。

public:
 virtual property cli::array <System::Globalization::Calendar ^> ^ OptionalCalendars { cli::array <System::Globalization::Calendar ^> ^ get(); };
public virtual System.Globalization.Calendar[] OptionalCalendars { get; }
member this.OptionalCalendars : System.Globalization.Calendar[]
Public Overridable ReadOnly Property OptionalCalendars As Calendar()

プロパティ値

現在の CultureInfo が表すカルチャで使用できる暦を表す Calendar 型の配列。

次のコード例は、カルチャでサポートされているバージョンを GregorianCalendar 確認する方法を示しています。

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)

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

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

End Class


'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)

注釈

アプリケーションでは、 クラスのインスタンスである の プロパティDateTimeFormatCalendar設定して、現在CultureInfoの で使用される予定表をDateTimeFormatInfo変更します。 新しい予定表は、 に一覧表示されている OptionalCalendars予定表のいずれかである必要があります。 DateTimeFormat には、その Calendarに関連付けられている日付と時刻の書式設定をカスタマイズする他のプロパティも含まれています。

適用対象

こちらもご覧ください