Consider the following three interfaces:
interface IBaseInterface
{
event EventHandler SomeEvent;
}
interface IInterface1 : IBaseInterface
{
...
}
interface IInterface2 : IBaseInterface
{
...
}
Now consider the following class that implements both IInterface1 and IInterface 2:
class Foo : IInterface1, IInterface2
{
event EventHandler IInterface1.SomeEvent
{
add { ... }
remove { ... }
}
event EventHandler IInterface2.SomeEvent
{
add { ... }
remove { ... }
}
}
This results in an error because SomeEvent is not part of IInterface1 or IInterface2, it is part of IBaseInterface.
How can the class Foo implement both IInterface1 and IInterface2?
You can use generics:
SomeEvent isn't part of IInterface1 or IInterface2, its a part of IBaseInterface.