5
Answers

Interfaces

Joël Phaka

Joël Phaka

9y
533
1
Hi, I have an Interface and I have a Class:
 
namespace Demo
{
   public interface IAB
   {
      void Greet(); 
   } 
    
   public class AB
   {
      public void Hello(IAB e ) 
      {
          e.Greet();
      } 
   }
}
___________________________________________________________________________________
The problem is how do I implement  the interface IAB as a parameter when I call the method Hello :
 
AB  ab = new  AB();
ab.Hello( how do I implement the interface inside here?  ) ;
 
I know how to do it in Java using anonymous classes or lambda expression. 
How can I do it in C#.
 
PLEASE HELP  .......

Answers (5)