My Thoughts & Views

Funtion to Find whether the String is Palindrome or Not

Posted on: March 27, 2007

using System;

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;
}
}

4 Responses to "Funtion to Find whether the String is Palindrome or Not"

I think you need to test your work.

I think you need to test your work.

Thanks for correcting me. Now you can check it out.

Thanks for correcting me. Now you can check it out.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog Stats

  • 70,599 hits
March 2007
M T W T F S S
« Feb   Apr »
 1234
567891011
12131415161718
19202122232425
262728293031  

Top Clicks

  • None
%d bloggers like this: