TimeSpan - FromNow
A TimeSpan extension method that add the specified TimeSpan to the current DateTime.
public static void Main() { var timeSpan = new TimeSpan(1, 0, 0, 0); // C# Extension Method: TimeSpan - FromNow DateTime value = timeSpan.FromNow(); // return tomorrow. Console.WriteLine(value.ToFullDateTimeString()); }
View Source
using System; public static partial class Extensions { /// <summary> /// A TimeSpan extension method that add the specified TimeSpan to the current DateTime. /// </summary> /// <param name="this">The @this to act on.</param> /// <returns>The current DateTime with the specified TimeSpan added to it.</returns> public static DateTime FromNow(this TimeSpan @this) { return DateTime.Now.Add(@this); } }