Coffeehouse Post

Single Post Permalink

View Thread: C# Extension Properties?
  • User profile image
    Ion Todirel

    mabster wrote:
    Yeah, I was hoping for extension properties too:

    public static TimeSpan Minutes[this int i]
       getreturn new TimeSpan(0, i, 0); }

    public static DateTime Ago[this TimeSpan ts]
       get { return DateTime.Now.Subtract(ts); }

    So then I could do:

    DateTime d = 20.Minutes.Ago;

    No ugly parentheses!
    yeah but its confusing and is too close to an an indexer