Complete the code to reverse a string using a built-in method.
string reversed = new string(input.ToCharArray().[1]().ToArray());The Reverse() LINQ extension method reverses the order of the characters after converting the string to a char array.
Complete the code to reverse a string using a for loop.
for (int i = input.Length - 1; i >= [1]; i--) { reversed += input[i]; }
The loop starts from the last character index and goes down to 0 to reverse the string.
Fix the error in the code that reverses a string using recursion.
return input.Length == 0 ? "" : input[input.Length - 1] + [1](input.Substring(0, input.Length - 1));
The recursive call must use the correct method name ReverseString to work properly.
Fill both blanks to reverse a string using a character array and a for loop.
char[] chars = input.[1](); for (int i = 0; i < chars.[2]; i++) { reversed = chars[i] + reversed; }
ToCharArray() converts the string to a char array, and Length gives the number of characters to loop through.
Fill all three blanks to reverse a string using LINQ methods.
string reversed = new string(input.[1]().[2]().ToArray()); // [3] is used to convert back to string
ToCharArray() converts the string to characters, Reverse() reverses them, and new string() converts the array back to a string.
