Alex Rivera | Logout

Should extension properties be added to C# 4.0?

Asked 2008-09-26T04:28:28.270
17

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#
Edit
Report

2 Answers

9

It's about databinding, let's say I have an object for binding to my UI and I want to hide show it based on other properties of the object. I could add an extension property for IsVisible or Visibility and bind that property to the UI.

You can't bind extension methods, but being able to add properties for databinding to existing types you can't extend could be very useful.

answered 2009-03-06T14:48:27.230
1

I guess it would be great, as long as there's no or minimal performance penalty in using them.

answered 2008-09-26T04:34:41.610

Your Answer