Monday, July 23, 2007

Function to find palindrome or not without Reversing the string

////Function to find palindrome or not without Reversing the string

private bool IsPalindrome(string str)
{
if((str==null) || (str.Length==0))
return false;
bool r=true;
for (int i = 0,n=str.Length-1; i < n && r; i++, n--)
r = str[i] == str[n];
return r;
}

No comments:

Post a Comment

Please post your comments here.....