Guest User

Guest User

  • Tech Writer
  • 32
  • 7k

Interfaces

Mar 28 2015 8:43 AM
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)