Coffeehouse Post

Single Post Permalink

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

    TommyCarlier said:
    How is 20.Minutes.Ago more confusing than DateTime.Now.Subtract(new TimeSpan(0, 20, 0))?
    It's not.  However, there are side effects.  Having the ability to write DateTime.Now.Ago is definitely confusing.  The Ago property would show up on all DateTimes (provided the using statement is there).  The idea is good, though.  Having an int extension property named MinutesAgo seems better.

    I too would have liked to see extension properties.  We have custom properties that we read from the DB and are generating them onto classes.  We are forced to use the ugly GetPropertyname() syntax.