Add Years - CSharp System

CSharp examples for System:DateTime Year

Description

Add Years

Demo Code

// (c) Copyright Microsoft Corporation.
using System.Windows.Markup;
using System.Windows;
using System.Globalization;
using System.Diagnostics;
using System;//from  w  w  w.  java2  s . c  om

public class Main{
        public static DateTime? AddYears(DateTime time, int years)
        {
            try
            {
                return cal.AddYears(time, years);
            }
            catch (System.ArgumentException)
            {
                return null;
            }
        }
}

Related Tutorials