Interfaces and Events



Hey everyone, I need some advice concerning Interfaces and delegates.

I would like to define a delegate inside of an interface (I know a
delegate is a class but hear me out)


Here is a sample:

Interface A

Class B inherits Interface A

Program C creates an instance of Class B and needs to consume events
from Class B.

I would like for Class B to be required to implement the delegates via
Interface A. Is this possible? Is this proper? Can/Should I use an
abstract class for this? Is there a better way?

.



Relevant Pages

  • Re: Delegates VS interfaces - some confusion
    ... the reason that an interface with three methods is not relevant is   ... implementor) having a direct access to all three methods? ... delegates) due to security reasons, ... giving us member level polymorphism?! ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Interfaces and Events
    ... you have the queue as the focus point. ... William Stacey [MVP] ... Instead of using delegates and events, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Delegates VS interfaces - some confusion
    ... the reason that an interface with three methods is not relevant is that a three-method interface is different from the single-method characteristic of a delegate. ... That is, with a three-method interface, any code with a reference to an implementor of that interface has access to all three methods. ... wrapping delegates inside ‘CurrentDelegate’ property), ... private void MethodA() ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Delegates and Event to replace with Interface?
    ... Regards ... i can replace the interface with delegates and events as shown on my previous example. ... > int funcB(); ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Delegates and Event to replace with Interface?
    ... i can replace the interface with delegates ... > interface IChildA ... > int funcB(); ... > After look into your article, is it possible to replace interfaces into delegates. ...
    (microsoft.public.dotnet.languages.csharp)

Loading