Export (0) Print
Expand All

EastAsianLunisolarCalendar.AlgorithmType Property

Updated: September 2010

Gets a value indicating whether the current calendar is solar-based, lunar-based, or a combination of both.

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

public override CalendarAlgorithmType AlgorithmType { get; }

Property Value

Type: System.Globalization.CalendarAlgorithmType
This property always returns the LunisolarCalendar value.

The following example uses reflection to instantiate each Calendar type found in the .NET Framework and displays the value of its AlgorithmType property.

using System;
using System.Collections;
using System.Globalization;
using System.Reflection;

public class Example
{
   public static void Main()
   {
      Assembly assem = Assembly.GetAssembly(typeof(Calendar));
      Type[] types = assem.GetExportedTypes();
      Type[] calendars = Array.FindAll(types, IsValidCalendar);
      Array.Sort(calendars, new CalendarComparer());

      Console.WriteLine("{0,-30} {1}\n", "Calendar", "Algorithm Type");
      foreach (var cal in calendars) {
         // Instantiate a calendar object.
         ConstructorInfo ctor = cal.GetConstructor( new Type[] {} );
         Calendar calObj = (Calendar) ctor.Invoke( new Type[] {} ); 

         Console.WriteLine("{0,-30} {1}", 
                          cal.ToString().Replace("System.Globalization.", ""),
                          cal.InvokeMember("AlgorithmType", 
                                           BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty,
                                           null, calObj, null));
      }
   }

   private static bool IsValidCalendar(Type t)
   {
        if (t.IsSubclassOf(typeof(Calendar)))
            if (t.IsAbstract)
                return false;
            else 
                return true;
        else 
            return false;
   }
}

public class CalendarComparer : IComparer
{
   public int Compare(object x, object y)
   {
      Type tX = (Type) x;
      Type tY = (Type) y;

      return tX.Name.CompareTo(tY.Name);
   }
}
// The example displays the following output: 
//       Calendar                       Algorithm Type 
//        
//       ChineseLunisolarCalendar       LunisolarCalendar 
//       GregorianCalendar              SolarCalendar 
//       HebrewCalendar                 LunisolarCalendar 
//       HijriCalendar                  LunarCalendar 
//       JapaneseCalendar               SolarCalendar 
//       JapaneseLunisolarCalendar      LunisolarCalendar 
//       JulianCalendar                 SolarCalendar 
//       KoreanCalendar                 SolarCalendar 
//       KoreanLunisolarCalendar        LunisolarCalendar 
//       PersianCalendar                SolarCalendar 
//       TaiwanCalendar                 SolarCalendar 
//       TaiwanLunisolarCalendar        LunisolarCalendar 
//       ThaiBuddhistCalendar           SolarCalendar 
//       UmAlQuraCalendar               LunarCalendar

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Date

History

Reason

September 2010

Added an example.

Customer feedback.

Community Additions

ADD
Show:
© 2014 Microsoft