Hi Ohad,
Thank you for posting in the community!
Based on my understanding, you want to explicit implement an interface
which takes an event field.
=============== =============== ============
Actually, when implementing an event that was declared in an interface, you
must use property syntax, which takes accessor(For event, they are "add"
and "remove").
Please refer to:
http://msdn.microsoft.com/library/de...us/cscomp/html
/vcerrCompilerEr rorCS0071.asp
Also, you can implicit implement an interface without using the prooperty
syntax:
public interface IFoo
{
event EventHandler MyEvent;
}
public class MyClass: IFoo
{
public event System.EventHan dler MyEvent;
}
That is because implicit implemented fields are part of the CLASS, while
the explicit implemented fields are part of the INTERFACE.
For a class, use compiler will generate code for field like event:
class X {
public event D Ev;
}
could be compiled to something equivalent to:
class X {
private D __Ev; // field to hold the delegate
public event D Ev {
add {
lock(this) { __Ev = __Ev + value; }
}
remove {
lock(this) { __Ev = __Ev - value; }
}
}
}
For more information, please refer to:
http://msdn.microsoft.com/library/de...us/csspec/html
/vclrfcsharpspec _10_7.asp
While as a field of interface, compiler will not do this for you, so you
must explicit the event through property syntax(Just as Jared pointed out):
public class MyClass : IFoo
{
event EventHandler IFoo.MyEvent
{
add { ... }
remvoe { ... }
}
}
Also, you may find more information about implement the event through:
http://msdn.microsoft.com/library/de...us/csref/html/
vclrfeventpg.as p
=============== =============== =============== ===============
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.