Hi,
While C# appeared similar to C++ on paper, I have started to struggle learning it. I started off with creating a generic matrix class, but soon simplified the problem to a class doing binary operations.
The problem is that it issues the error "CS0019: Operator '+' cannot be applied to operands of type 'T' and 'T'". Could someone please help?Code:internal interface IBinaryOperations< T > { T Add( T val1, T val2 ); T Subtract( T val1, T val2 ); T Multiply( T val1, T val2 ); T Divide( T val1, T val2 ); } public class CBinaryOperations< T > : IBinaryOperations< T > { public static T Add( T val1, T val2 ) { return( val1 + val2 ); } public static T Subtract( T val1, T val2 ) { return( val1 - val2 ); } public static T Multiply( T val1, T val2 ) { return( val1 * val2 ); } public static T Divide( T val1, T val2 ) { return( val1 / val2 ); } }
Thanks
SB




Reply With Quote