Coffeehouse Post

Single Post Permalink

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

    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!