Hi all,
I have a string like
string str = "I love Microsoft very much";
and then I want output as follows (beware of uppercase and lowercase):
much very Microsoft love I
How do I do this in C# ?
waiting for your reply.
Loading
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.
SenthilkumarPosted Feb 23, 2012, 11:30 PM
This will do the reverse of the words....
string str = "I love Microsoft Very much";
string[] _words = str.split(" ");
string strReverse = string.empty;
for(int i=_Words.Length;i>0;i--)
{
strReverse += _words[i] + " ";
}
Console.WriteLine(strReverse);
Pramod Kumar NandagiriPosted Feb 23, 2012, 12:08 PM
Sorry i didn't read the post correctly...
VulpesPosted Feb 23, 2012, 11:55 AM
Also mine won't work either if word separators other than spaces are to be allowed (comma, period etc), though it's not difficult to allow for this.
Pramod Kumar NandagiriPosted Feb 23, 2012, 11:49 AM
string s2=string.Empty;
for (int i = str.Length; i > 0; i--)
{
s2 += str[i-1];
}
Response.Write(s2);
VulpesPosted Feb 23, 2012, 9:17 AM