When porting to c#, the compiler complains,
Google says to use the where keyword to constrain the template T, but still no joy. Google also implies that Templates (generics in c#) are provided, but not to be used for simple things like math ops or logic. Simply want to use this template on Doubles and Ints.
Any c# experts in the room to offer advice on templates? Or is it easier to manage two classes, one for Double, and one for Int?
thanks
//template <class T> class maximin<T> where T : struct{ private T _mmin; private T _mmax; public T mmin{ get { return _mmin;} set {_mmin = value;} } public T mmax{ get { return _mmax;} set {_mmax = value;} } public maximin( T a, T b ){ // constructor _mmin = a; _mmax = b; } public T getMax(){ return (_mmax); } public T getMin(){ return (_mmin); } public bool isBetween( T b ){ return ( b < _mmax && b > _mmin ? true : false ); } public T getSize(){ return _mmax - _mmin; } }
Comment