Implement multiple generic interfaces by a non-generic class : Generic Interface : Generic C# Examples


C# Examples » Generic » Generic Interface »

 

Implement multiple generic interfaces by a non-generic class









    
using  System;
using  System.Collections.Generic;

interface  GenericInterface<T>                                                        
{
      T  getValue(T  inValue);
}

class  MyClass  :  GenericInterface<int>,  GenericInterface<string>        
{
      public  int  getValue(int  inValue)                        
      {
            return  inValue;
      }

      public  string  getValue(string  inValue)            
      {
            return  inValue;
      }
}

class  MainClass
{
      static  void  Main()
      {
            MyClass  TrivInt  =  new  MyClass();
            MyClass  TrivString  =  new  MyClass();

            Console.WriteLine("{0}",  TrivInt.getValue(5));
            Console.WriteLine("{0}",  TrivString.getValue("Hi  there."));
      }
}
    
   
  
   



Output

5
Hi there.


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Generic
» Generic Interface