Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.50/5 (4 votes)
See more:
I want C# CODE for String reverse with out using for loop , while loop , do while loop, and String reverse Functions ie inbuilt functions also ,Please share u have any solution
thanks
sandeep m
Posted
Updated 16-Jan-13 3:57am
v2
Comments
Sandeep Mewara 16-Jan-13 10:23am    
It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.

You can use an Array to do this -
C#
char[] arr = myStr.ToCharArray();
11.Array.Reverse(arr );
12.return new string(arr );


You are however, using Array reverse in this case.
 
Share this answer
 
You know C# provides the (in)famous goto:
C#
public static string reverse(string s)
{
  string r = string.Empty;
  int i= s.Length-1;
  L1:
  if (i<0) return r;
  r = r + s[i];
  i--;
  goto L1;
}
 
Share this answer
 
Comments
StM0n 16-Jan-13 5:01am    
You're having a lot of fun, don't you :)
fjdiewornncalwe 16-Jan-13 9:59am    
I'd like to see what his instructor says when he hands this one in.
Normally I would chastise you for giving code to a blatant homework question, but in this case it would be the OP's own fault if he handed this in.
CPallini 16-Jan-13 10:11am    
Well, is is a legal solution to OP's problem.

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