Pages

Subscribe:

Ads 468x60px

Thursday, March 22, 2012

how to reverse a string in asp.net using c#

In this web Programming tutorial we will learn that how we can print a string in reverse mode in asp.net using c#,
for example you have a string as below
string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
and you want to print or show it in Reverse mode as below, Output: ZYXWVUTSRQPONMLKJIHGFEDCBA here is the code you can use in ur .cs file and can use as per your requirement. function call.
 string teest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        test.Text = Reverse(teest);
actual function defination
     public string Reverse(string str)
         {
              int len = str.Length;
              char[] arr = new char[len];

                for (int i = 0; i < len; i++)
                {
                    arr[i] = str[len - 1 - i];
                }

                    return new string(arr);
         }

No comments:

Post a Comment