2
Reply

How to reverse number in C#

Kirtesh Shah

Kirtesh Shah

1y
711
0
Reply

How to reverse number in C#

    The LINQ version is definitely more concise and readable for simple cases. I'd probably use new string(original.Reverse().ToArray())844 unless performance is critical or I'm working with very large strings!

    Two way there one is Reverse the character array and other is using Linq query

    string original = \”Hello, World!\”;
    char[] charArray = original.ToCharArray();
    Array.Reverse(charArray);
    string reversed = new string(charArray);

    1. Console.WriteLine(reversed); \/\/ Output: !dlroW ,olleH
    2. }

    }
    string original = \”Hello, World!\”;
    string reversed = new string(original.Reverse().ToArray());

    1. Console.WriteLine(reversed); \/\/ Output: !dlroW ,olleH