To Year Start - CSharp System

CSharp examples for System:DateTime Year

Description

To Year Start

Demo Code


using System;/*from  w  ww.j  av  a 2s.  c om*/

public class Main{
        public static DateTime ToYearStart(this DateTime value)
        {
            return new DateTime(value.Year, 1, 1);
        }
        public static DateTime ToYearStart(this string value)
        {
            DateTime date = Convert.ToDateTime(value);
            return new DateTime(date.Year, 1, 1);
        }
}

Related Tutorials