Coffeehouse Post

Single Post Permalink

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

    mabster said:
    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!
    Hah.  Reminds me of a query I saw recently.  At my new job, we communicate alot with an ancient DB2 system; someone posted a query like:

    Select * from abc.defg
    where dt = ? - 180 days

    I was like, what? Awesome.

    Then someone showed me that TOP 10 is now FETCH FIRST 10 ROWS ONLY.  And the awe was gone.

    Don't get me started.