This is an example of using the Markdown Snippets global tool to keep code samples up to date.

Calculator

The Calculator class allows us to do basic arithmetic.

public interface ICalculator
{
    int Add(int x, int y);
    int Minus(int x, int y);
    int Multiply(int x, int y);
    int Divide(int x, int y);
}

snippet source | anchor

We can new up a new calculator using the following code.

var calculator = new Calculator();

snippet source | anchor

Add

We can add two int parameters together.

result = calculator.Add(1, 1);
// result is 2
Console.WriteLine(result);

snippet source | anchor

Minus

We can subtract an int parameter from another.

result = calculator.Minus(1, 1);
// result is 0
Console.WriteLine(result);

snippet source | anchor

Multiply

We can multiply int parameters together.

result = calculator.Multiply(2, 2);
// result is 4
Console.WriteLine(result);

snippet source | anchor

Divide

We can divide an int numerator against an int denominator.

result = calculator.Divide(4, 2);
// result is 2
Console.WriteLine(result);

snippet source | anchor