how spin 3 methods controlling c# generics?
i have used generics many can't figure out illusory spin following 3 methods controlling generics devaluate duplication. indeed formula now 6 methods nonetheless solve 3 following rest should only work anyway same solution.
private vigilant evaluateuint64(uint64 x, uint64 y)
{
switch (operation)
{
box binaryop.add:
relapse x + y;
box binaryop.subtract:
relapse x - y;
box binaryop.multiply:
relapse x * y;
box binaryop.divide:
relapse x / y;
box binaryop.remainder:
relapse x % y;
default:
pitch new applicationexception("error");
}
}
private vigilant evaluatefloat(float x, boyant y)
{
switch(operation)
{
box binaryop.add:
relapse x + y;
box binaryop.subtract:
relapse x - y;
box binaryop.multiply:
relapse x * y;
box binaryop.divide:
relapse x / y;
box binaryop.remainder:
relapse x % y;
default:
pitch new applicationexception("error");
}
}
private vigilant evaluatedouble(double x, double y)
{
switch (operation)
{
box binaryop.add:
relapse x + y;
box binaryop.subtract:
relapse x - y;
box binaryop.multiply:
relapse x * y;
box binaryop.divide:
relapse x / y;
box binaryop.remainder:
relapse x % y;
default:
pitch new applicationexception("error");
}
}
i am building rudimentary countenance parser following needs weigh rudimentary binary operations such addition/subtraction etc. i above methods tangible maths achieved controlling applicable types. nonetheless there got improved answer!
Comments
Post a Comment