Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Gibt die Anzahl der Tage im angegebenen Monat und Jahr zurück.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Shared Function DaysInMonth ( _
year As Integer, _
month As Integer _
) As Integer
'Usage
Dim year As Integer
Dim month As Integer
Dim returnValue As Integer
returnValue = DateTime.DaysInMonth(year, month)
public static int DaysInMonth (
int year,
int month
)
public:
static int DaysInMonth (
int year,
int month
)
public static int DaysInMonth (
int year,
int month
)
public static function DaysInMonth (
year : int,
month : int
) : int
Parameter
- year
Das Jahr.
- month
Der Monat (eine Zahl zwischen 1 und 12).
Rückgabewert
Die Anzahl der Tage in month für das angegebene year. Wenn month gleich 2 für Februar ist, ist der Rückgabewert 28 oder 29, abhängig davon, ob year ein Schaltjahr ist.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
month ist kleiner als 1 oder größer als 12. – oder – year ist kleiner als 1 oder größer als 9999. |
Beispiel
Im folgenden Codebeispiel wird die DaysInMonth-Methode veranschaulicht.
Const July As Integer = 7
Const Feb As Integer = 2
' daysInJuly gets 31.
Dim daysInJuly As Integer = System.DateTime.DaysInMonth(2001, July)
' daysInFeb gets 28 because the year 1998 was not a leap year.
Dim daysInFeb As Integer = System.DateTime.DaysInMonth(1998, Feb)
' daysInFebLeap gets 29 because the year 1996 was a leap year.
Dim daysInFebLeap As Integer = System.DateTime.DaysInMonth(1996, Feb)
const int July = 7;
const int Feb = 2;
// daysInJuly gets 31.
int daysInJuly = System.DateTime.DaysInMonth(2001, July);
// daysInFeb gets 28 because the year 1998 was not a leap year.
int daysInFeb = System.DateTime.DaysInMonth(1998, Feb);
// daysInFebLeap gets 29 because the year 1996 was a leap year.
int daysInFebLeap = System.DateTime.DaysInMonth(1996, Feb);
const int July = 7;
const int Feb = 2;
// daysInJuly gets 31.
int daysInJuly = System::DateTime::DaysInMonth( 2001, July );
// daysInFeb gets 28 because the year 1998 was not a leap year.
int daysInFeb = System::DateTime::DaysInMonth( 1998, Feb );
// daysInFebLeap gets 29 because the year 1996 was a leap year.
int daysInFebLeap = System::DateTime::DaysInMonth( 1996, Feb );
final int july = 7;
final int feb = 2;
// daysInJuly gets 31.
int daysInJuly = System.DateTime.DaysInMonth(2001, july);
// daysInFeb gets 28 because the year 1998 was not a leap year.
int daysInFeb = System.DateTime.DaysInMonth(1998, feb);
// daysInFebLeap gets 29 because the year 1996 was a leap year.
int daysInFebLeap = System.DateTime.DaysInMonth(1996, feb);
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0