Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

TaiwanCalendar.IsLeapYear Method (Int32, Int32)

Determines whether the specified year in the specified era is a leap year.

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

'Declaration
Public Overrides Function IsLeapYear ( _
	year As Integer, _
	era As Integer _
) As Boolean

Parameters

year
Type: System.Int32

An integer that represents the year.

era
Type: System.Int32

An integer that represents the era.

Return Value

Type: System.Boolean
true if the specified year is a leap year; otherwise, false.

ExceptionCondition
ArgumentOutOfRangeException

year is outside the range supported by the calendar.

-or-

era is outside the range supported by the calendar.

Leap years in the Taiwan calendar correspond to the same leap years in the Gregorian calendar. A leap year in the Gregorian calendar is defined as a Gregorian year that is evenly divisible by four, except if it is divisible by 100. However, Gregorian years that are divisible by 400 are leap years. A common year has 365 days and a leap year has 366 days.

The following example calls IsLeapYear for five years in each of the eras.

Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic

Public Class SamplesTaiwanCalendar   

   Public Shared Sub Main()

      ' Creates and initializes a TaiwanCalendar. 
      Dim myCal As New TaiwanCalendar()

      ' Displays the header.
      Console.Write("YEAR" + ControlChars.Tab)
      Dim y As Integer 
      For y = 90 To 94
         Console.Write(ControlChars.Tab + "{0}", y)
      Next y
      Console.WriteLine()

      ' Checks five years in the current era.
      Console.Write("CurrentEra:")
      For y = 90 To 94
         Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapYear(y, TaiwanCalendar.CurrentEra))
      Next y
      Console.WriteLine()

      ' Checks five years in each of the eras. 
      Dim i As Integer 
      For i = 0 To myCal.Eras.Length - 1
         Console.Write("Era {0}:" + ControlChars.Tab, myCal.Eras(i))
         For y = 90 To 94
            Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapYear(y, myCal.Eras(i)))
         Next y
         Console.WriteLine()
      Next i

   End Sub 'Main 

End Class 'SamplesTaiwanCalendar


'This code produces the following output. 



'YEAR            90      91      92      93      94 

'CurrentEra:     False   False   False   True    False 

'Era 1:          False   False   False   True    False

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft