Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Palindrome Number C# - better solution

Copy
public class Solution {
    public bool IsPalindrome(int x) {
        string k = x.ToString();        
        
        for(int i=0;i<k.Length/2;i++)   
        {
            if(k[i] != k[k.Length-1-i]) 
            {
                return false;           // if any char not the same, return false
            }
        }
        return true;                    
    }
}
Source by zyrastory.com #
 
PREVIOUS NEXT
Tagged: #Palindrome #Number #solution
ADD COMMENT
Topic
Name
1+9 =