The good thing I like about .net 4.0 is that we now can make extensions using static classes like above. We would use a slightly different approach and change
double a
to
this double a
and the resulting code would look like this
internal static class Arithematic
{
public static double Multiply(this double a, double b)
{
return a * b;
}
public static double Divide(this double a, double b)
{
return a / b;
}
public static double Subtract(this double a, double b)
{
return a - b;
}
public static double Add(this double a, double b)
{
return a + b;
}
}
Now we don't have to use
double d = Arithematic.Add(25.5, 25.5);
to get the value of 51. We can simply call
double result = ((double)25.5).Add(25.5);