is Palindrome number - CSharp System

CSharp examples for System:Math Number

Description

is Palindrome number

Demo Code


using System;/*  w ww  . j  av  a 2 s . c  o m*/

public class Main{
        public static bool isPalindrome(int n) {
         var nArray = n.ToString().ToCharArray();

         for (var i = 0; i < nArray.Length / 2; i++) {
            if (nArray[i] != nArray[nArray.Length - i - 1]) {
               return false;
            }
         }

         return true;
      }
}

Related Tutorials