public class MyClass { public delegate void SetStringDelegate( string value); public string MyProperty { get{ return myProperty; } set{ myProperty = value; } } public void DoTest() { /* This gives compile error "cannot explicitly call ... accessor" */ SetStringDelegate SetString = new SetStringDelegate( set_MyProperty); /* This gives compile error "Property ... used like ... Method" */ SetStringDelegate SetString2 = new SetStringDelegate( MyProperty) } } |
Is it possible to wrap a property setter directly with a delegate?
I tried the following without success. I don't want to have to code a separate method just so I can pass the setter function to another class as I'm going to be doing this a lot.

Is it possible to wrap a property setter directly with a delegate?
RahulGangwar
However, how about suggesting that this be implemented on the Microsoft Product Feedback Center.
DoomGoober
magrute
The request is at http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx feedbackid=e9496dee-5fab-41eb-882c-247898daa19d
The good news is that there are a couple of workarounds. One looks like it'll work for me. The other uses reflection which I'm afraid will add too much overhead (I'll be doing this a lot.)