Reverse each word of the sentence (string) in c#
public class StringDataStructure
{
// Reverse each word of the sentence
public string ReverseEachString(string _title)
{
string result = "";
if (string.IsNullOrEmpty(_title))
return string.Empty;
string[] arr = _title.Split(" ");
for (int i = 0; i < arr.Length; i++)
{
if (i != arr.Length - 1)
{
result += ReverseString(arr[i]) + " ";
}
else
{
result += ReverseString(arr[i]) + " ";
}
}
return result;
}
}