Table of Contents

Class Calculator

Namespace
CalculatorLibrary
Assembly
CalculatorLibrary.dll

Performs basic arithmetic operations on integers.

public class Calculator
Inheritance
Calculator
Inherited Members

Remarks

This is the sample class the template ships with. When you start your own project, replace it (and CalculatorCli) with your own domain classes — see docs/guide/from-topic-to-project.en.md for the step-by-step walkthrough.

Methods

Add(int, int)

Adds two integers.

public int Add(int a, int b)

Parameters

a int

The first addend.

b int

The second addend.

Returns

int

The sum of a and b.

Divide(int, int)

Divides one integer by another using integer (truncating) division.

public int Divide(int a, int b)

Parameters

a int

The dividend.

b int

The divisor.

Returns

int

The integer quotient of a divided by b.

Exceptions

DivideByZeroException

Thrown when b is zero.

Multiply(int, int)

Multiplies two integers.

public int Multiply(int a, int b)

Parameters

a int

The first factor.

b int

The second factor.

Returns

int

The product of a and b.

Subtract(int, int)

Subtracts one integer from another.

public int Subtract(int a, int b)

Parameters

a int

The value to subtract from.

b int

The value to subtract.

Returns

int

The result of a minus b.