Check Palindrome Number from a string


 static void Main(string[] args)
        {
           
            Console.WriteLine(" Enter string");
            string s = Console.ReadLine();
            Console.WriteLine(PalindromNo(s));
            Console.ReadLine();
        }


 public static string PalindromNo(string str)
        {
            string strOut = string.Empty;
            string revs = string.Empty;
            if (!string.IsNullOrEmpty(str))
            {
                for (int i = str.Length-1; i >= 0; i--)
                {
                    revs += str[i].ToString();
                }


                if (revs == str)
                {
                    strOut = "YES";
                }
                else
                    strOut = "No";
            }
            else
                strOut = "Enter a string to check palindrom";

            return strOut;
        }

Comments

Popular posts from this blog

Solution of This Error : Error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

How to creat slideshow in javascript