Kirtesh Shah
How to determine whether a String is a Palindrome or not in C#?

How to determine whether a String is a Palindrome or not in C#?

By Kirtesh Shah in .NET on Dec 06 2024
  • Anurag Deshmukh
    Jan, 2025 12

    Store the pallidrome var and check if it if they are equal

    • 0
  • Sangeetha S
    Jan, 2025 10

    static bool IsPalindrome(string str)
    {
    \/\/ Normalize the string
    str = str.ToLower();
    str = new string(Array.FindAll(str.ToCharArray(), char.IsLetterOrDigit));
    char[] charArray = str.ToCharArray();
    Array.Reverse(charArray);
    string reversedStr = new string(charArray);
    \/\/ Compare original and reversed string
    return str == reversedStr;
    }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS