Reverse word of full sentence

You would need to split the string into words and the reverse those instead of reversing the characters:

text = String.Join(" ", text.Split(' ').Reverse())

In framework 3.5:

text = String.Join(" ", text.Split(' ').Reverse().ToArray())

In framework 2.0:

string[] words = text.Split(' ');
Array.Reverse(words);
text = String.Join(" ", words);

Leave a Comment