Example 1: C# program to reverse the given string
Program.cs
string s = "KODINGWINDOW";
Console.WriteLine(s.Reverse().ToArray());
Output
kodingwindow@kw:~/csharp$ dotnet run
WODNIWGNIDOK
kodingwindow@kw:~/csharp$ 
Example 2: C# program to reverse the given string
Program.cs
string s = "KODINGWINDOW";
char[] arr = s.ToCharArray();
Array.Reverse(arr);
Console.WriteLine(arr);
Output
kodingwindow@kw:~/csharp$ dotnet run
WODNIWGNIDOK
kodingwindow@kw:~/csharp$ 
Example 3: C# program to reverse the given string
Program.cs
string r = "", s;
s = "KODINGWINDOW";
int len = s.Length - 1;
while (len >= 0)
{
    r = r + s[len];
    len--;
}
Console.WriteLine(r);
Output
kodingwindow@kw:~/csharp$ dotnet run
WODNIWGNIDOK
kodingwindow@kw:~/csharp$ 
Advertisement