strinvg c# reverse code example
Example 1: c# reverse string
public static string ReverseString(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
Example 2: reverse a string in c#
public void ReverseString(char[] s) {
for(int i = 0; i < s.Length / 2; i++) {
char temp = s[i];
s[i] = s[s.Length - 1 - i];
s[s.Length - 1 - i] = temp;
}
}