Reference Type Constraint : Generic Constraint : Generics C# Source Code


Custom Search

C# Source Code » Generics » Generic Constraint »

 

Reference Type Constraint








    
 
using System;
using System.Collections;


public class Starter {
    public static void Main() {
        // MyClass<int> obj1=new MyClass<int>(); [illegal]
        MyClass<XClass> obj2 = new MyClass<XClass>();

    }
}

public class MyClass<T> where T : class {

    public void Iterate(T data) {
    }
}

public class XClass {
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Generics
» Generic Constraint