| Code to reverse a string in c# console application
Below is the code to reverse the string first i have put the string in char[] datatypes. And after that using for loop we have reverse the string character by character. Here i have use console application.
internal static void RevStr(string str)
{
char[] charOfArray = str.ToCharArray();
for (int i = 0, j = str.Length - 1; i < j; i++, j--)
{
charOfArray[i] = str[j];
charOfArray[j] = str[i];
}
string reversestring = new string(charOfArray);
Console.WriteLine(reversestring);
}
| | |