Month Of Total Day - CSharp System

CSharp examples for System:DateTime Month

Description

Month Of Total Day

Demo Code


using System.Globalization;
using System.Text.RegularExpressions;
using System.Web;
using System.Linq;
using System.Collections.Generic;
using System;//from  w  ww  . j av a  2  s .  c o m

public class Main{
            public static int MonthOfTotalDay(int year, int month)
            {
                if (year <= 0001 || year >= 9999) return -1;
                if (month < 1 || month > 12) return -1;
                return DateTime.DaysInMonth(year, month);
            }
            public static int MonthOfTotalDay()
            {
                DateTime _now = DateTime.Now;
                return DateTime.DaysInMonth(_now.Year, _now.Month);
            }
}

Related Tutorials