Coffeehouse Post

Single Post Permalink

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

    GaryC said:
    TommyCarlier said:
    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.
    Actually, as he wrote it the "Ago" property would show up on TimeSpan, not on DateTime, which makes a lot more sense. So you wouldn't actually be able to do DateTime.Now.Ago.