hi! i wanted to make a program to reverse the users input i.e-
"This is c# example" to "example c# is the"
any idea how to go about doing this ?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Akhil GargRank #772 · 3K reputationPosted Jan 20, 2015, 6:05 PM EST
Hi Noaman,
Just split that input into array of string and then display that array in reverse order You can directly use split function to split string based on ' ' this character
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 20, 2015, 6:22 PM EST
Try This.
protected void Page_Load(object sender, EventArgs e)
{
string Name = "This Is Manish";
Response.Write(Name + "
");
Response.Write(Reverse(Name));
}
public string Reverse( string s)
{
var result = s.Split(' ');
return string.Join(" ", result.Reverse());
}
o/p:- Manish Is This
Khargesh RajputRank #616 · 3.9K reputationPosted Jan 20, 2015, 6:27 PM EST
string[] words = s.Split(' ');
Array.Reverse(words);
lblMsg.Text= string.Join(" ", words);
output: example c# is the
Noaman Khalil32 reputationPosted Jan 21, 2015, 12:49 AM EST
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 21, 2015, 1:15 AM EST
How you implement my code in your project. It's working fine.
Khargesh RajputRank #616 · 3.9K reputationPosted Jan 21, 2015, 1:55 AM EST
Implement properly
Noaman Khalil32 reputationPosted Jan 21, 2015, 4:45 AM EST
VulpesRank #55 · 29.2K reputationPosted Jan 21, 2015, 11:42 AM EST