# How to find the opposite number in C#?

## How to find the opposite number in C#? #csharp #dotnet #math

Jan 10, 2023

We want to return the opposite number.

Examples:

`1: -1`

14: -14

-34: 34

`public static int Opposite(int number) { return -number; }`

Solution

Another solution is:

`return n * -1;`

A SO reference:

https://stackoverflow.com/questions/1059480/math-opposite-sign-function

Kata from codewars:

https://www.codewars.com/kata/56dec885c54a926dcd001095/train/csharp

Read more about Math Functions:

- Ceil
- Floor
- Sinh / Cosh
- Asin / Acos
- Log

https://www.educba.com/math-functions-in-c-sharp/

These functions can be important if you’re going to work with numbers.