Use interface as a parameter : Class as Parameter : Class C# Examples


C# Examples » Class » Class as Parameter »

 

Use interface as a parameter









    
interface  Animal
{
}

class  Dog  :  Animal
{
}

class  Cat  :  Animal
{
}

class  MainClass
{
      static  void  ListenToMe(  Animal  listener  )
      {
      }
      
      static  void  Main()
      {
            Dog  dog  =  new  Dog();
            Cat  cat  =  new  Cat();

            ListenToMe(  dog  );
            ListenToMe(  cat  );
      }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Class as Parameter