Monday, January 10, 2011

String reversal, without using String operations

The below code will perform of the reverse of the string without using any string methods.
private void reverseString()
    {
    string str = "SANTHOSH";
    int i = 0;
    foreach (char c in str)
      {
      i++;
      }
    for (int j = i - 1; j >= 0; j--)
      {
      Response.Write(str[j]);
      }
    }
Result : HSOHTNAS

No comments:

Post a Comment