指定した月および年の日数を返します。
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
Public Shared Function DaysInMonth ( _
year As Integer, _
month As Integer _
) As Integer
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
パラメータ
- year
年。
- month
月 (1 から 12 までの範囲の数)。
戻り値
指定した year の month の日数。
たとえば、month が 2 月を表す 2 に等しい場合、戻り値には、year が閏年かどうかによって 28 または 29 を返します。
DaysInMonth メソッドのコード例を次に示します。
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);
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0