class test
{
private static void Main()
{
Console.WriteLine("Is 'ada' Palindrome : {0}",IsPalindrome("ada"));
Console.ReadLine();
}
public static bool IsPalindrome(String strParam)
{
int iLength,iHalfLength;
iLength = strParam.Length - 1;
iHalfLength = iLength/2;
for(int iIndex=0;iIndex<=iHalfLength;iIndex++)
{
if(strParam.Substring(iIndex,1)!=strParam.Substring(iLength - iIndex,1))
{
return false;
}
}
return true;
}
}
2 comments:
I think you need to test your work.
Thanks for correcting me. Now you can check it out.
Post a Comment