public static long ReverseNumber(this long number)

{

` long reversedNumber = 0;`

bool isNegative = false;

` if (number < 0)`

{

` isNegative = true;`

}

` if (number < 10 && number >= 0)`

{

reversedNumber = number;

` return reversedNumber;`

}

number = Math.Abs(number);

` while (number > 0)`

{

reversedNumber = _base * reversedNumber + number % _base;

number = number / _base;

}

` if (isNegative)`

{

reversedNumber = reversedNumber * -1;

}

` return reversedNumber;`

}

Test Case

Number 1234567890 is reversed to 987654321

Number -123456 is reversed to -654321

Number 9 is reversed to 9

Number 545 is reversed to 545

Number 123454321 is reversed to 123454321

Number -123454321 is reversed to -123454321