ankur ankur - 11 months ago 55
C# Question

Check if a string is a palindrome

I have a string as input and have to break the string in two substrings. If the left substring equals the right substring than do some logic.

How can I do this?


public bool getStatus(string myString)


= "ankYkna", so if we break it into two substring it would be:
left-part = "ank".
right-part = "ank" (after reversal).

Answer Source
public static bool getStatus(string myString)
        string first = myString.Substring(0, myString.Length / 2);
        char[] arr = myString.ToCharArray();
        string temp = new string(arr);
        string second = temp.Substring(0, temp.Length / 2);
        return first.Equals(second);