Detemine whether an integer is palindrome. An integer is a palindrome when it reads the same backward as forward.
/*
* Detemine whether an integer is palindrome. An integer is a palindrome when it reads the same backward as forward.
*/
public bool LeetCode_9(int x)
{
bool ans = false;
char[] buf = x.ToString().ToCharArray();
int len = buf.Length;
if (x < 0)
return false;
else
{
for (int i=0; i<(len/2);i++)
{
if (buf[i] != buf[len - i - 1])
{
return false;
}
}
ans = true;
}
return ans;
}