다음을 통해 공유


CultureInfo.OptionalCalendars 속성

culture에서 사용할 수 있는 달력 목록을 가져옵니다.

네임스페이스: System.Globalization
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Overridable ReadOnly Property OptionalCalendars As Calendar()
‘사용 방법
Dim instance As CultureInfo
Dim value As Calendar()

value = instance.OptionalCalendars
public virtual Calendar[] OptionalCalendars { get; }
public:
virtual property array<Calendar^>^ OptionalCalendars {
    array<Calendar^>^ get ();
}
/** @property */
public Calendar[] get_OptionalCalendars ()
public function get OptionalCalendars () : Calendar[]

속성 값

현재 CultureInfo로 표시되는 culture에서 사용할 수 있는 달력을 나타내는 Calendar 형식의 배열입니다.

설명

DateTimeFormatInfo 클래스의 인스턴스인 DateTimeFormatCalendar 속성을 설정하여 현재 CultureInfo에 사용되는 달력을 변경할 수 있습니다. 새 달력은 OptionalCalendars에 표시된 달력 중 하나여야 합니다. DateTimeFormat에는 Calendar와 연관된 날짜 및 시간 형식을 사용자 지정하는 다른 속성도 포함되어 있습니다.

예제

다음 코드 예제에서는 culture에서 지원하는 GregorianCalendar 버전을 확인하는 방법을 보여 줍니다.

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)

*/
import System.* ;
import System.Globalization.* ;

public class SamplesCultureInfo
{
    public static void main(String[] args)
    {
        // Gets the calendars supported by the ar-SA culture.
        Calendar myOptCals[] = (new CultureInfo("ar-SA")).
            get_OptionalCalendars();

        // Checks which ones are GregorianCalendar then determines the 
        // GregorianCalendar version.
        Console.WriteLine
            ("The ar-SA culture supports the following calendars:");
        
        for (int iCtr = 0; iCtr < myOptCals.length; iCtr++) {
            Calendar cal = myOptCals[iCtr];
            if (cal.GetType() == GregorianCalendar.class.ToType()) {
                GregorianCalendar myGreCal = ((GregorianCalendar)(cal));
                GregorianCalendarTypes calType = myGreCal.get_CalendarType();
                Console.WriteLine("   {0} ({1})", cal, calType);
            }
            else {
                Console.WriteLine("   {0}", cal);
            }
        }
    } //main 
} //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)
*/

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

CultureInfo 클래스
CultureInfo 멤버
System.Globalization 네임스페이스
Calendar 클래스
CultureInfo.DateTimeFormat 속성
DateTimeFormatInfo