KoreanCalendar.IsLeapYear(Int32, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷指定紀元中指定的年份是否為閏年。
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
表示紀元的整數。
傳回
如果指定的年份為閏年,則為 true
,否則為 false
。
例外狀況
範例
下列範例會在每個紀元中呼叫 IsLeapYear 五年。
using namespace System;
using namespace System::Globalization;
int main()
{
// Creates and initializes a KoreanCalendar.
KoreanCalendar^ myCal = gcnew KoreanCalendar;
// Displays the header.
Console::Write( "YEAR\t" );
for ( int y = 4334; y <= 4338; y++ )
Console::Write( "\t {0}", y );
Console::WriteLine();
// Checks five years in the current era.
Console::Write( "CurrentEra:" );
for ( int y = 4334; y <= 4338; y++ )
Console::Write( "\t {0}", myCal->IsLeapYear( y, KoreanCalendar::CurrentEra ) );
Console::WriteLine();
// Checks five years in each of the eras.
for ( int i = 0; i < myCal->Eras->Length; i++ )
{
Console::Write( "Era {0}:\t", myCal->Eras[ i ] );
for ( int y = 4334; y <= 4338; y++ )
Console::Write( "\t {0}", myCal->IsLeapYear( y, myCal->Eras[ i ] ) );
Console::WriteLine();
}
}
/*
This code produces the following output.
YEAR 4334 4335 4336 4337 4338
CurrentEra: False False False True False
Era 1: False False False True False
*/
using System;
using System.Globalization;
public class SamplesKoreanCalendar {
public static void Main() {
// Creates and initializes a KoreanCalendar.
KoreanCalendar myCal = new KoreanCalendar();
// Displays the header.
Console.Write( "YEAR\t" );
for ( int y = 4334; y <= 4338; y++ )
Console.Write( "\t{0}", y );
Console.WriteLine();
// Checks five years in the current era.
Console.Write( "CurrentEra:" );
for ( int y = 4334; y <= 4338; y++ )
Console.Write( "\t{0}", myCal.IsLeapYear( y, KoreanCalendar.CurrentEra ) );
Console.WriteLine();
// Checks five years in each of the eras.
for ( int i = 0; i < myCal.Eras.Length; i++ ) {
Console.Write( "Era {0}:\t", myCal.Eras[i] );
for ( int y = 4334; y <= 4338; y++ )
Console.Write( "\t{0}", myCal.IsLeapYear( y, myCal.Eras[i] ) );
Console.WriteLine();
}
}
}
/*
This code produces the following output.
YEAR 4334 4335 4336 4337 4338
CurrentEra: False False False True False
Era 1: False False False True False
*/
Imports System.Globalization
Public Class SamplesKoreanCalendar
Public Shared Sub Main()
' Creates and initializes a KoreanCalendar.
Dim myCal As New KoreanCalendar()
' Displays the header.
Console.Write("YEAR" + ControlChars.Tab)
Dim y As Integer
For y = 4334 To 4338
Console.Write(ControlChars.Tab + "{0}", y)
Next y
Console.WriteLine()
' Checks five years in the current era.
Console.Write("CurrentEra:")
For y = 4334 To 4338
Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapYear(y, KoreanCalendar.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 = 4334 To 4338
Console.Write(ControlChars.Tab + "{0}", myCal.IsLeapYear(y, myCal.Eras(i)))
Next y
Console.WriteLine()
Next i
End Sub
End Class
'This code produces the following output.
'
'YEAR 4334 4335 4336 4337 4338
'CurrentEra: False False False True False
'Era 1: False False False True False
備註
韓曆中的閏年對應至公曆中的相同閏年。 公曆中的閏年會定義為公曆的公曆年,此年會平均除以四,除非以100除。 不過,由 400 除的公曆年是閏年。 一般年份有 365 天,而閏年有 366 天。