当前位置: 首页>>代码示例>>C#>>正文


C# TaiwanCalendar.AlgorithmType属性代码示例

本文整理汇总了C#中System.Globalization.TaiwanCalendar.AlgorithmType属性的典型用法代码示例。如果您正苦于以下问题:C# TaiwanCalendar.AlgorithmType属性的具体用法?C# TaiwanCalendar.AlgorithmType怎么用?C# TaiwanCalendar.AlgorithmType使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。


在下文中一共展示了TaiwanCalendar.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);
   }
}
开发者ID:.NET开发者,项目名称:System.Globalization,代码行数:51,代码来源:TaiwanCalendar.AlgorithmType

输出:

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


注:本文中的System.Globalization.TaiwanCalendar.AlgorithmType属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。