Click to See Complete Forum and Search --> : How to define a delegate that will have the form a property?


sharong
March 10th, 2005, 03:28 AM
I wand to define a delegate that will have the form a property and not a method.

Let say I have a property:

public int myProp
{
get { return 0; }
set {}
}

And I want to have a delegate that will take this property as the handler.

Is it possible?
How do I do that?

-----------------------
Thanks in advance
Sharon

Norfy
March 10th, 2005, 05:21 AM
Is it possible? No!

A delegate expects a target and a method to invoke on it.

A property is syntatic sugar for get_Property and set_Property, however, new CustomDelegate(this.get_Property) is not allowed by the compiler.