Extension Methods and Syntax Semantics

Posted Posted 1/30/2010 12:46:19 PM

If we have Extension methods:


public static TimeSpan Days(this int input) { return TimeSpan.FromDays(input); }

public static DateTime Ago(this TimeSpan input) { return (DateTime.Now - input); }



Then we can:


DateTime when = 24.Days().Ago();



Pretty neat, huh?



Project Codename MV8
Copyright © 2010 Kevin Connolly. All rights reserved.
Your request ate 40 of my milliseconds.