0

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

5
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by cVz
0

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

0

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

1

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 by happygeek: fixed formatting

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.