Use multiple where clauses : where clause : Generics C# Source Code


Custom Search

C# Source Code » Generics » where clause »

 

Use multiple where clauses








    


using System;

// Gen has two type arguments and both have
// a where clause.
class Gen<T, V> where T : class
                where V : struct {
  T ob1;
  V ob2;

  public Gen(T t, V v) {
    ob1 = t;
    ob2 = v;
  }
}

class Test {
  public static void Main() {
    Gen<string, int> obj = new Gen<string, int>("test", 11);

    // The next line is wrong because bool is not
    // a reference type.
//    Gen<bool, int> obj = new Gen<bool, int>(true, 11);

  }
}
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Generics
» where clause