reverse words in string c# code example
Example 1: reverse string c#
string str = "Hello World!";
string reverse = "";
int length = str.Length - 1;
while(length >= 0)
{
reverse += str[length];
length--;
}
Console.WriteLine(reverse);
Example 2: c# reverse a string and case
using System.Linq;
public class Hello{
public static void Main(){
string inputstring="AbcdeFhiJKl";
char[] arr = new char[inputstring.Length];
int i=0;
foreach (char v in inputstring.Select(x => x).Reverse())
{
if (char.IsUpper(v)) { arr[i]=char.ToLower(v); }else{ arr[i]=char.ToUpper(v);};
i=i+1;
}
string str = new string(arr);
System.Console.WriteLine(str);
System.Console.ReadLine();
}
}