My Question in C#.Net is like this
string str= "Hello World Welcome";
How to get the Output: "WelCome World Hello".
Please Help me
Regards
Hari
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishnujeet KumarPosted Nov 28, 2012, 10:08 AM
class HelloWorld
{
string value = "Hello World Welcome";
string reversestring = string.Empty;
char charSplit = ' ';
string[] Hellowords = value.Split(new char[] { charSplit }, StringSplitOptions.RemoveEmptyEntries);
foreach (string word in Hellowords)
{
reversestring = word + charSplit + reversestring;
}
Console.WriteLine(reversestring);
Console.ReadKey();
}
VulpesPosted Nov 28, 2012, 9:48 AM
I've assumed that 'WelCome' is a typo and you meant 'Welcome'.