Create relationship between two type parameters : Generic Parameter : Generic C# Examples


C# Examples » Generic » Generic Parameter »

 

Create relationship between two type parameters









    
using  System;  
  
class  A  {  
}  
  
class  B  :  A  {  
}  
  
//  Here,  V  must  inherit  T.  
class  Gen<T,  V>  where  V  :  T  {    
}  
  
class  MainClass  {  
    public  static  void  Main()  {  
        Gen<A,  B>  x  =  new  Gen<A,  B>();  
  
        //  error  
        //  Gen<B,  A>  y  =  new  Gen<B,  A>();  
  
    }  
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Generic
» Generic Parameter