Coffeehouse Post

Single Post Permalink

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

    spivonious said:
    I'm probably in the minority here, but I think the whole extension methods concept is confusing.  If you want to add a method to a class, then subclass it.  That's why inheritance exists, and it makes a lot more sense to me when I see MyTimeSpan.Ago rather than TimeSpan.Ago, because I might go searching the MSDN for documentation on TimeSpan.Ago only to find it doesn't exist.
    >  If you want to add a method to a class, then subclass it.

    What if the class you want to add a method to is sealed or worse, is a struct, preventing you from doing just that? Not unlike DateTime, TimeSpan or String?