How to reverse each word in a string using c#?
Dipendra Singh Shekhawat
string.reverse() can be used.
String to be reversed:DS tech blogOutput or the reversed string:SD hcet golbHow to reverse each word in a string using c#Our Logic in CSharp (C#): string input = "DS tech blog";string result = string.Join(" ", input.Split(' ').Select(x => new String(x.Reverse().ToArray())));Console.WriteLine(result);Remember to include the below using statements: using System; using System.Linq; Explanation for the above code:Split the input string using a single space as the separator.Split() method for returning a string array that contains each word of the input string.Select method for constructing a new string array, by reversing each character in each word.Join method for converting the string array into a string.