Svish Svish - 1 month ago 24
C# Question

Does C# have extension properties?

Does C# have extension properties?

For example, can I add an extension property to

DateTimeFormatInfo
called
ShortDateLongTimeFormat
which would return
ShortDatePattern + " " + LongTimePattern
?

Answer

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.