When trying to call this function in my code i get the error in the title. Also Operator \'+=\' cannot be applied to the operands of type \'int\' and \'T\'
p
It knows not how to add your T
to a numeric since it doesnt know what the type of T
is going to be.
t += Convert.ToInt32(value);
But since you are adding int
to int
and returning int
then why not just ditch the generic parameter and make it
public int Change(Stats type, int value)
and if you want different behaviour for different types and really want the same method name, instead of testing the type just do:
public int Change(Stats type, string value)
public int Change(Stats type, DateTime value)