HijriCalendar.GetDaysInMonth(Int32, Int32, Int32) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce il numero di giorni nel mese specificato dell'anno e dell'era specificati.
public:
override int GetDaysInMonth(int year, int month, int era);
public override int GetDaysInMonth(int year, int month, int era);
override this.GetDaysInMonth : int * int * int -> int
abstract member GetDaysInMonth : int * int * int -> int
override this.GetDaysInMonth : int * int * int -> int
Public Overrides Function GetDaysInMonth (year As Integer, month As Integer, era As Integer) As Integer
Parametri
- year
- Int32
Intero che rappresenta l'anno.
- month
- Int32
Intero compreso tra 1 e 12 che rappresenta il mese.
- era
- Int32
Intero che rappresenta l'era.
Valori restituiti
Numero di giorni nel mese specificato nell'anno specificato nell'era specificata.
Eccezioni
era non è compreso nell'intervallo supportato da questo calendario.
oppure
year non è compreso nell'intervallo supportato da questo calendario.
oppure
month non è compreso nell'intervallo supportato da questo calendario.
Esempio
Nell'esempio di codice seguente viene chiamato GetDaysInMonth il dodicesimo mese in ognuno di cinque anni in ogni era.
using System;
using System.Globalization;
public class SamplesHijriCalendar {
public static void Main() {
// Creates and initializes a HijriCalendar.
HijriCalendar myCal = new HijriCalendar();
// Displays the header.
Console.Write( "YEAR\t" );
for ( int y = 1421; y <= 1425; y++ )
Console.Write( "\t{0}", y );
Console.WriteLine();
// Displays the value of the CurrentEra property.
Console.Write( "CurrentEra:" );
for ( int y = 1421; y <= 1425; y++ )
Console.Write( "\t{0}", myCal.GetDaysInMonth( y, 12, HijriCalendar.CurrentEra ) );
Console.WriteLine();
// Displays the values in the Eras property.
for ( int i = 0; i < myCal.Eras.Length; i++ ) {
Console.Write( "Era {0}:\t", myCal.Eras[i] );
for ( int y = 1421; y <= 1425; y++ )
Console.Write( "\t{0}", myCal.GetDaysInMonth( y, 12, myCal.Eras[i] ) );
Console.WriteLine();
}
}
}
/*
This code produces the following output. The results might vary depending on
the settings in Regional and Language Options (or Regional Options or Regional Settings).
YEAR 1421 1422 1423 1424 1425
CurrentEra: 29 29 30 29 29
Era 1: 29 29 30 29 29
*/
Imports System.Globalization
Public Class SamplesHijriCalendar
Public Shared Sub Main()
' Creates and initializes a HijriCalendar.
Dim myCal As New HijriCalendar()
' Displays the header.
Console.Write("YEAR" + ControlChars.Tab)
Dim y As Integer
For y = 1421 To 1425
Console.Write(ControlChars.Tab + "{0}", y)
Next y
Console.WriteLine()
' Displays the value of the CurrentEra property.
Console.Write("CurrentEra:")
For y = 1421 To 1425
Console.Write(ControlChars.Tab + "{0}", myCal.GetDaysInMonth(y, 12, HijriCalendar.CurrentEra))
Next y
Console.WriteLine()
' Displays the values in the Eras property.
Dim i As Integer
For i = 0 To myCal.Eras.Length - 1
Console.Write("Era {0}:" + ControlChars.Tab, myCal.Eras(i))
For y = 1421 To 1425
Console.Write(ControlChars.Tab + "{0}", myCal.GetDaysInMonth(y, 12, myCal.Eras(i)))
Next y
Console.WriteLine()
Next i
End Sub
End Class
'This code produces the following output. The results might vary depending on
'the settings in Regional and Language Options (or Regional Options or Regional Settings).
'
'YEAR 1421 1422 1423 1424 1425
'CurrentEra: 29 29 30 29 29
'Era 1: 29 29 30 29 29
Commenti
Ad esempio, questo metodo restituisce 29 o 30 per Zulhijjah (month = 12), a seconda che year sia un anno bisestile.