Goal :
My intention to design a utility that could access any numeric values( int,double,byte...) and produce the squares.
What i did:
delegate void t<T> (T somevalues);
class program
{
static void Main()
{
Console.ReadKey(true);
}
}
class Utility
{
public static void Activities<T>(T[] SomeValues,t<T> transformer)
{
var qry = SomeValues.Select(p => transformer(p));
}
public static T Squaring<T>(T vals)
{
return vals * vals;
}
}
Error :
Try to specify explicit type argument ( in LINQ query).
Operator '*' cannot be applied to operands of type 'T' and 'T' ( in Squaring( ) ).
How can i derive constraint or change the code that can access any numerics(int,double,byte,..) and produce the square.