You can print any string in reverse order by using below code, even no need to use any inbuild method of asp.net.
#Step 1. Create one method as
Now call this method any where, i am calling in page_load event as
#Step 1. Create one method as
PrintWordsInReverseOrder(string str)
static string PrintWordsInReverseOrder(string str) { string revWord = string.Empty; string finalSentance = string.Empty; for (int i = 0; i < str.Length; i++) { if (str[i] != ' ') { revWord = str[i] + revWord; } else { revWord = revWord + ' '; finalSentance = finalSentance + revWord; revWord = string.Empty; } } if (revWord != string.Empty) finalSentance = finalSentance + revWord; return finalSentance; }
Now call this method any where, i am calling in page_load event as
protected void Page_Load(object sender, EventArgs e) { Response.Write(PrintWordsInReverseOrder("Test String")); }