I've wanted this for fluent interfaces. See, for example this Channel9 discussion. Would probably require also adding indexed properties.
What are your thoughts? Would the advantages outweigh the "language clutter"?
C# already supports extension methods which allow for extending existing objects without altering the core contract/shape in any way, which provides a lot of benefit in when trying to add helper, convention, fluent style additions to a given type.
Extension properties are values associated with the extension. They are quite similar to regular data properties, wherein you map a key of type string with a value string. The main purpose is to store data configurations for the extension.
In C#, the extension method concept allows you to add new methods in the existing class or in the structure without modifying the source code of the original type and you do not require any kind of special permission from the original type and there is no need to re-compile the original type.
No. Extension methods require an instance of an object.
Since properties are just syntactic sugar for methods, I don't see why C# should have extension methods without extension properties.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With