If you are looking forward to find the reverse of a number in C# , below is a sample source code that demonstrates how to do it using extension methods in c#.
Finding the Reverse of a Number in C# using Extension Methods
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GinktageConsoleApp
{
internal class Program
{
private static void Main(string[] args)
{
int input = 4761;
Console.WriteLine(input.Reverse()); ;
Console.ReadLine();
}
}
public static class Helper
{
public static int Reverse(this int value)
{
int retValue = value;
int OutPut = 0;
while (retValue > 0)
{
int rem = retValue % 10;
OutPut = (OutPut * 10) + rem;
retValue = retValue / 10;
}
return OutPut;
}
}
}