Method for getting previous year - CSharp System

CSharp examples for System:DateTime Year

Description

Method for getting previous year

Demo Code


using System.Threading;
using System.Globalization;
using System.Collections.Generic;
using System;//  ww  w  .  j  a  v  a2s.c om

public class Main{
        /// <summary>
        /// Method for getting previous year
        /// </summary>
        /// <param name="date">Date</param>
        /// <returns>Previous year</returns>
        public static DateTime GetPreviousYear(this DateTime date)
        {
            return date.AddYears(-1);
        }
}

Related Tutorials