Let’s say the following is the string −
Welcome
After reversing the string, the words should be visible like −
emocleW
Use the reverse() method and try the following code to reverse words in a string −
Example
using System;
using System.Linq;
class Demo {
static void Main() {
string str = "Welcome";
// reverse the string
string res = string.Join(" ", str.Split(' ').Select(s => new String(s.Reverse().ToArray())));
Console.WriteLine(res);
}
}