How to check palindrome in asp.net?


Hi
In so many time, they will ask this question in interview to check the programming skill of developer.

How can check the palindrome string like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

public partial class Program_Palindrom_of_String : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
string s = TextBox1.Text.ToString();
string str = string.Empty;
for (int j = s.Length-1; j >= 0; j–)
{
//store the reverse string
str = str + s[j];
}
//check with input value
if (s == str)
{
Label1.Text = s + " is palindrom";
}
else
{
Label1.Text = s + " is not palindrom";
}
}
}

Advertisements

2 Responses to “How to check palindrome in asp.net?”

  1. vidhya Says:

    thank u its useful for me

    • Chandra Dev Says:

      Nice to know.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: