Does C# have extension properties?

Svish picture Svish · Mar 6, 2009 · Viewed 218.5k times · Source

Does C# have extension properties?

For example, can I add an extension property to DateTimeFormatInfo called ShortDateLongTimeFormat which would return ShortDatePattern + " " + LongTimePattern?

Answer

JaredPar picture JaredPar · Mar 6, 2009

No they do not exist in C# 3.0 and will not be added in 4.0. It's on the list of feature wants for C# so it may be added at a future date.

At this point the best you can do is GetXXX style extension methods.