i am curious about this palindrome....is there somebody give me some code so that i have a background knowledge to this topic,

What's more to say, it reads the same forwards as it does backwards. Separate the string to individual chars using the substring method.

well, the following code should do it:

bool CheckPalindrome (string CheckString)
{
     if (CheckString == null || CheckString.Length == 0) 
     {
        return false;
     }
     for (int i = 0; i < CheckString.Length / 2; i++)
     {
         if (CheckString[i] != CheckString[CheckString.Length - 1 - i])
         {
            return false;
         }
     }
     return true;
}

hope this helped
pygmalion

This code may help you.

public bool PolinDrome()
{
string str = "atita";
int len = str.Length;
string strReverse = "";
for (int i = len - 1; i >= 0; i--)
{


strReverse = strReverse + str;
}
if (strReverse == str)
{
return true;
}
else
{
return false;
}


}

Edited 3 Years Ago by happygeek: fixed formatting

You can try something like this

public static bool IsPalindrome(string strValue)
        {
            int intLen, intStrPartLen;
            intLen = strValue.Length - 1;

            //Cut the length of the string into 2 halfs
            intStrPartLen = intLen / 2;

            for (int intIndex = 0; intIndex <= intStrPartLen; intIndex++)
            {
                //intIndex is the index of the char in the front of the string
                //Check from behind and front for match
                if (strValue[intIndex] != strValue[intLen])
                {
                    return false;
                }
                //decrease the lenght of the original string to
                //test the next Char from behind
                intLen--;
            }
            return true;
        }

You have fun now

This article has been dead for over six months. Start a new discussion instead.