C# Extension Methods
Nosirbek
Posted on May 9, 2022
public static class MyExtensions
{
public static int Reverse(this int num)
{
int result=0;
while (num != 0)
{
result = result*10 + num%10;
num /= 10;
}
return result;
}
}
public class Program
{
public static void Main(string[] args)
{
int a = -12345;
System.Console.WriteLine(a.Reverse());
}
}
Result
-54321
💖 💪 🙅 🚩
Nosirbek
Posted on May 9, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024