本文整理汇总了C#中System.Globalization.GregorianCalendar.AlgorithmType属性的典型用法代码示例。如果您正苦于以下问题:C# GregorianCalendar.AlgorithmType属性的具体用法?C# GregorianCalendar.AlgorithmType怎么用?C# GregorianCalendar.AlgorithmType使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Globalization.GregorianCalendar
的用法示例。
在下文中一共展示了GregorianCalendar.AlgorithmType属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
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);
}
}
输出:
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