C# program to reverse each word of a sentence separately?
a C# program to reverses each word in a sentence except these punctuation marks (? ! . ,)
example: (input) this is john, who are you?
(output) sith si nhon, ohw era uoy?
_______________________________________...
here's my code which reverses punctuation marks too and removes the space character in the output.. :,(
string str = Console.ReadLine();
string strrev = "";
foreach (var word in str.Split(' '))
{
string temp = "";
foreach (var ch in word.ToCharArray())
{
temp = ch + temp;
}
strrev = strrev + temp + "";
}
Console.WriteLine(strrev);
Console.ReadLine();