Returns the FIRST possible time unit for provided YEAR in dateTime - CSharp System

CSharp examples for System:DateTime Year

Description

Returns the FIRST possible time unit for provided YEAR in dateTime

Demo Code


using System.Globalization;
using System;/*from   w  ww  . jav a2  s  . c  om*/

public class Main{
        /// <summary>
        /// Returns the FIRST possible time unit for provided YEAR in dateTime
        /// </summary>
        public static DateTime StartOfYear(this DateTime dateTime)
        {
            var startOfYear = new DateTime(dateTime.Year, 1, 1);

            return startOfYear;
        }
}

Related Tutorials