當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET Calendar.AlgorithmType屬性代碼示例

本文整理匯總了VB.NET中System.Globalization.Calendar.AlgorithmType屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET Calendar.AlgorithmType屬性的具體用法?VB.NET Calendar.AlgorithmType怎麽用?VB.NET Calendar.AlgorithmType使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在System.Globalization.Calendar的用法示例。


在下文中一共展示了Calendar.AlgorithmType屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: Example

' 導入命名空間
Imports System.Collections
Imports System.Globalization
Imports System.Reflection

Module Example
   Public Sub Main()
      Dim assem As Assembly = Assembly.GetAssembly(GetType(Calendar))
      Dim types() As Type = assem.GetExportedTypes()
      Dim calendars() As Type = Array.FindAll(types, AddressOf IsValidCalendar)
      Array.Sort(calendars, New CalendarComparer())

      Console.WriteLine("{0,-30} {1}", "Calendar", "Algorithm Type")
      Console.WriteLine()
      For Each cal In calendars
         ' Instantiate a calendar object.
         Dim ctor As ConstructorInfo = cal.GetConstructor( {} )
         Dim calObj As Calendar = CType(ctor.Invoke( {} ), Calendar) 

         Console.WriteLine("{0,-30} {1}", 
                          cal.ToString().Replace("System.Globalization.", ""),
                          cal.InvokeMember("AlgorithmType", 
                                           BindingFlags.Public Or BindingFlags.Instance Or BindingFlags.GetProperty,
                                           Nothing, calObj, Nothing))
      Next
   End Sub
   
   Private Function IsValidCalendar(ByVal t As Type) As Boolean
        If t.IsSubClassOf(GetType(Calendar)) Then
            If t.IsAbstract Then
                Return False
            Else
                Return True
            End If
        Else
            Return False
        End If
    End Function
End Module

Public Class CalendarComparer : Implements IComparer
   Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer _
                  Implements IComparer.Compare
      Dim tX As Type = DirectCast(x, Type)
      Dim tY As Type = DirectCast(y, Type)

      Return tX.Name.CompareTo(tY.Name)
   End Function
End Class
開發者ID:VB.NET開發者,項目名稱:System.Globalization,代碼行數:49,代碼來源:Calendar.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.Calendar.AlgorithmType屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。