Click here to Skip to main content
16,019,514 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi How can I read string,reverse it and print it in one line
thanks
Posted
Comments
André Kraak 30-Sep-11 19:30pm    
What did you try yourself?
Please post any code you have and tell us your problems with it.

If you wish to change your question use the Improve Question button.

This will help you..
Use Console.ReadLine() for read a line..
string  str = "sdvsd fgfgd dfhsjhf";
//str=Console.ReadLine();
char[] a;
a = strError.ToCharArray();
Array.Reverse(a);
string s = new string(a);
Console.WriteLine(s);
 
Share this answer
 
It might help you,

C#
// To do the Job in One line code.
Console.ReadLine().Reverse().ToList().ForEach(ch => Console.Write(ch));
//Or
// Read the userinput first and then apply the rule to reverse it.
var input = Console.ReadLine();
Console.WriteLine(string.Join(string.Empty, input.Reverse().ToArray()));


:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900