Home > Forum > C# > How to make entered sentence in reverse order using C#

How to make entered sentence in reverse order using C#

by Thamil   on Sep 14, 2014   Category: C#  |  Views: 1356    |  Points: 5   |  Gold 
  Reply
i need logic in c#.net to word reverse in the sense if my input is "hello dotnetspider" than output should be "dotnetspider hello"..
please provide the code

Question posted on behalf of nagendra prasad


Bookmark and Share:
 
  User Reply  | Ask a question  |   Reply 
  Re :How to make entered sentence in reverse order using C#   
by Thamil
on Sep 14 2014 2:53AM
Points : 10
Gold 
Hi Nagendra Prasad,

We can achieve this reversing a word in a sentence by using Array.Reverse() method in C#. See the below code.

string str = "hello dotnetspider";
string[] line = str.Split(' ');
Array.Reverse(line);
Response.Write(string.Join(" ", line));


Thanks.

Recent Post

Latest Posts