Home > Article > Backend Development > Reverse words in given string in C#
Assume the following is the string -
Welcome
After flipping the string, the words should be visible like −.
emocleW
Use reverse() method and try the following code to reverse the words in the string -
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); } }
The above is the detailed content of Reverse words in given string in C#. For more information, please follow other related articles on the PHP Chinese website!