共用方式為


UmAlQuraCalendar.IsLeapYear(Int32, Int32) 方法

定義

判斷指定紀元中指定的年份是否為閏年。

public:
 override bool IsLeapYear(int year, int era);
public override bool IsLeapYear (int year, int era);
override this.IsLeapYear : int * int -> bool
Public Overrides Function IsLeapYear (year As Integer, era As Integer) As Boolean

參數

year
Int32

一年。

era
Int32

一紀元。 指定 UmAlQuraCalendar.Eras[UmAlQuraCalendar.CurrentEra]UmAlQuraEra

傳回

如果指定的年份為閏年,則為 true,否則為 false

例外狀況

yearera 不在 UmAlQuraCalendar 類別支援的範圍內。

範例

下列範例會列出連續十年的天數,並呼叫 IsLeapYear 方法來判斷哪一年是閏年。

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      Calendar cal = new UmAlQuraCalendar();
      int currentYear = cal.GetYear(DateTime.Now);

      for (int year = currentYear; year <= currentYear + 9; year++)
         Console.WriteLine("{0:d4}: {1} days {2}", year,
                           cal.GetDaysInYear(year, UmAlQuraCalendar.UmAlQuraEra),
                           cal.IsLeapYear(year, UmAlQuraCalendar.UmAlQuraEra) ?
                              "(Leap Year)" : "");
   }
}
// The example displays the following output:
//       1431: 354 days
//       1432: 354 days
//       1433: 355 days (Leap Year)
//       1434: 354 days
//       1435: 355 days (Leap Year)
//       1436: 354 days
//       1437: 354 days
//       1438: 354 days
//       1439: 355 days (Leap Year)
//       1440: 354 days
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim cal As New UmAlQuraCalendar()
      Dim currentYear As Integer = cal.GetYear(Date.Now)
      
      For year As Integer = currentYear To currentYear + 9
         Console.WriteLine("{0:d4}: {1} days {2}", year, 
                           cal.GetDaysInYear(year, UmAlQuraCalendar.UmAlQuraEra), 
                           If(cal.IsLeapYear(year, UmAlQuraCalendar.UmAlQuraEra),
                              "(Leap Year)", ""))        
      Next   
   End Sub
End Module
' The example displays the following output:
'       1431: 354 days
'       1432: 354 days
'       1433: 355 days (Leap Year)
'       1434: 354 days
'       1435: 355 days (Leap Year)
'       1436: 354 days
'       1437: 354 days
'       1438: 354 days
'       1439: 355 days (Leap Year)
'       1440: 354 days

備註

一般年份有 354 天,而閏年有 355 天。

適用於