Is Palindrome in C#

using System;

namespace CheckStringForPalindrome
{
    class Program
    {
        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;
        }

        static void Main(string[] args)
        {
            string str;

            Console.Write("Please input:");
            str = Console.ReadLine();

            char[] strAry = str.ToCharArray();
            Array aStr = str.ToCharArray();
            Array.Reverse(aStr);
            string strreverse = string.Empty;
            foreach (char c in aStr) 
            { 
                strreverse = strreverse + c;
            }
            if (str.Equals(strreverse))
            {
                Console.WriteLine("String is poly" + System.Environment.NewLine);
            }
            else
            {
                Console.WriteLine("String is Not poly" + System.Environment.NewLine);
            }

        }
    }
}
Advertisements