Returns a date in the future by hours. - CSharp System

CSharp examples for System:DateTime Hour

Description

Returns a date in the future by hours.

Demo Code

//   The contents of this file are subject to the New BSD
using System;//w  w  w . java  2 s . co  m

public class Main{
        /// <summary>
    /// Returns a date in the future by hours.
    /// </summary>
    /// <param name="hours">The hours.</param>
    /// <returns></returns>
    public static DateTime HoursFromNow(this int hours) {
        TimeSpan t = new TimeSpan(hours, 0, 0);
        return DateTime.Now.Add(t);
    }
}

Related Tutorials