Method for getting last day in month - CSharp System

CSharp examples for System:DateTime Month

Description

Method for getting last day in month

Demo Code


using System.Threading;
using System.Globalization;
using System.Collections.Generic;
using System;//from  w w w  . ja va2 s.  co  m

public class Main{
        /// <summary>
        /// Method for getting last day in month
        /// </summary>
        /// <param name="date">Date</param>
        /// <returns>Last day in month</returns>
        public static DateTime GetLastDay(this DateTime date)
        {
            return new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));
        }
}

Related Tutorials