Check Whether a String is Palindrome or not

1:  public partial class Pallindrome : System.Web.UI.Page  
2:  {  
3:    protected void Page_Load(object sender, EventArgs e)  
4:    {  
5:      string Str="mam", Revstr = "";  
6:      for (int i = Str.Length - 1; i >= 0; i--)  
7:      {  
8:        Revstr = Revstr + Str[i];  
9:      }  
10:      if (Revstr == Str)  
11:      {  
12:        Response.Write("PALLINDROME");  
13:      }  
14:      else  
15:      {  
16:        Response.Write("NOT PALLINDROME");  
17:      }  
18:    }  
19:  }  

No comments:

Post a Comment