Create relationship between two type parameters : Generic Parameter « Generic « C# / CSharp Tutorial






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>(); 
 
  } 
}








18.15.Generic Parameter
18.15.1.Create relationship between two type parameters
18.15.2.Default generic parameter value