C# a program to reverse each word in the given string. code example
Example 1: C# a program to reverse each word in the given string.
var reversedWords = string.Join(" ",
str.Split(' ')
.Select(x => new String(x.Reverse().ToArray()))
.ToArray());
Example 2: C# a program to reverse each word in the given string.
string str = "I am going to reverse myself.";
string strrev = "";
foreach (var word in str.Split(' '))
{
string temp = "";
foreach (var ch in word.ToCharArray())
{
temp = ch + temp;
}
strrev = strrev + temp + "";
}
Console.WriteLine(strrev);
Example 3: C# a program to reverse each word in the given string.
var reversedWords = string.Join(" ",
str.Split(' ')
.Select(x => new String(x.Reverse().ToArray())));
Example 4: C# a program to reverse each word in the given string.
new String( word.Reverse().ToArray() )