none
revstr RRS feed

Answers

  • You should consider using a simple for loop that iterates through the characters of the string backwards:

      class Program {
          static void Main(string[] args)
          {
    
              string s = "test";
              Console.WriteLine(Reverse(s));
          }
    
          static string Reverse(string s)
          {
              StringBuilder sb = new StringBuilder();
              for (int i = s.Length - 1; i >= 0; i--)
              {
                  sb.Append(s[i]);
              }
    
              return sb.ToString();
          }
      }
    


    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Friday, October 2, 2015 3:01 PM

All replies

  • You should consider using a simple for loop that iterates through the characters of the string backwards:

      class Program {
          static void Main(string[] args)
          {
    
              string s = "test";
              Console.WriteLine(Reverse(s));
          }
    
          static string Reverse(string s)
          {
              StringBuilder sb = new StringBuilder();
              for (int i = s.Length - 1; i >= 0; i--)
              {
                  sb.Append(s[i]);
              }
    
              return sb.ToString();
          }
      }
    


    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Friday, October 2, 2015 3:01 PM
  • reverse the STRING  without using array ,strreverse ,mid ,please help me on this
    Sounds like a homework assignment.
    Friday, October 2, 2015 3:19 PM
  • ya ans me
    Friday, October 2, 2015 4:10 PM