共用方式為


CalendarAlgorithmType 列舉

定義

指定曆法是以陽曆為主、以陰曆為主,或以陰陽曆為主。

public enum class CalendarAlgorithmType
public enum CalendarAlgorithmType
[System.Runtime.InteropServices.ComVisible(true)]
public enum CalendarAlgorithmType
type CalendarAlgorithmType = 
[<System.Runtime.InteropServices.ComVisible(true)>]
type CalendarAlgorithmType = 
Public Enum CalendarAlgorithmType
繼承
CalendarAlgorithmType
屬性

欄位

LunarCalendar 2

以陰曆為主的曆法。

LunisolarCalendar 3

以陰陽曆為主的曆法。

SolarCalendar 1

以陽曆為主的曆法。

Unknown 0

未知的曆法基準。

範例

下列程式代碼範例示範 AlgorithmType 屬性和 CalendarAlgorithmType 列舉。

using namespace System;
using namespace System::Globalization;

namespace CalendarTypeExample
{
    static void Display(Calendar^ genericCalendar)
    {
        String^ calendarName = 
            genericCalendar->ToString()->PadRight(50, '.');
        Console::WriteLine("{0} {1}", calendarName, genericCalendar->GetType());
    }
}

int main() 
{
    GregorianCalendar^ gregorianCalendar = gcnew GregorianCalendar();
    HijriCalendar^ hijriCalendar = gcnew HijriCalendar();
    JapaneseLunisolarCalendar^ japaneseCalendar = 
        gcnew JapaneseLunisolarCalendar();
    CalendarTypeExample::Display(gregorianCalendar);
    CalendarTypeExample::Display(hijriCalendar);
    CalendarTypeExample::Display(japaneseCalendar);
    return 0;
}

/* This code example produces the following output.

System.Globalization.GregorianCalendar............ System.Globalization.GregorianCalendar
System.Globalization.HijriCalendar................ System.Globalization.HijriCalendar
System.Globalization.JapaneseLunisolarCalendar.... System.Globalization.JapaneseLunisolarCalendar

*/
// This example demonstrates the Calendar.AlgorithmType property and
// CalendarAlgorithmType enumeration.

using System;
using System.Globalization;

class Sample
{
    public static void Main()
    {
    GregorianCalendar grCal = new GregorianCalendar();
    HijriCalendar     hiCal = new HijriCalendar();
    JapaneseLunisolarCalendar
                      jaCal = new JapaneseLunisolarCalendar();
    Display(grCal);
    Display(hiCal);
    Display(jaCal);
    }

    static void Display(Calendar c)
    {
    string name = c.ToString().PadRight(50, '.');
    Console.WriteLine("{0} {1}", name, c.AlgorithmType);
    }
}
/*
This code example produces the following results:

System.Globalization.GregorianCalendar............ SolarCalendar
System.Globalization.HijriCalendar................ LunarCalendar
System.Globalization.JapaneseLunisolarCalendar.... LunisolarCalendar

*/
' This example demonstrates the Calendar.AlgorithmType property and
' CalendarAlgorithmType enumeration.
Imports System.Globalization

Class Sample
   Public Shared Sub Main()
      Dim grCal As New GregorianCalendar()
      Dim hiCal As New HijriCalendar()
      Dim jaCal As New JapaneseLunisolarCalendar()
      Display(grCal)
      Display(hiCal)
      Display(jaCal)
   End Sub
   
   Shared Sub Display(c As Calendar)
      Dim name As String = c.ToString().PadRight(50, "."c)
      Console.WriteLine("{0} {1}", name, c.AlgorithmType)
   End Sub
End Class
'
'This code example produces the following results:
'
'System.Globalization.GregorianCalendar............ SolarCalendar
'System.Globalization.HijriCalendar................ LunarCalendar
'System.Globalization.JapaneseLunisolarCalendar.... LunisolarCalendar
'

備註

特定行事曆的日期計算取決於行事曆是以太陽能為基礎、以月球為基礎或以 lunisolar 為基礎的。 例如, GregorianCalendarJapaneseCalendarJulianCalendar 類別是以太陽能為基礎、 HijriCalendarUmAlQuraCalendar 類別是以月球為基礎,而 HebrewCalendarJapaneseLunisolarCalendar 類別是以 lunisolar 為基礎,因此會針對月份和日使用月和月的月曆計算的太陽能計算。

CalendarAlgorithmType ,由行事歷成員傳回,例如 Calendar.AlgorithmType 屬性,指定特定行事曆的基礎。

適用於