where T: struct : where « Generic « C# / CSharp Tutorial






using System.Collections.Generic;

public class MyValueList<T> where T: struct
{
    private List<T> imp = new List<T>();
    
    public void Add( T v ) {
        imp.Add( v );
    }
}

public class MainClass
{
    static void Main() {
        MyValueList<int> intList = new MyValueList<int>();

        intList.Add( 123 );

        // CAN'T DO THIS.
        // MyValueList<object> objList = new MyValueList<object>();
    }
}








18.23.where
18.23.1.Use multiple where clauses
18.23.2.where T: struct
18.23.3.Generic Operator Overloading