A palindrome is a word, number, or other sequence of units that can be read the same way in either direction.Through below code sample,you can check whether string is a palindrome or not using c#.
You can check palindrome string with the help of While and for statement, check this:
Using While and If statement:
public bool IsPalindrome(string s) { int i = 0; int j = s.Length - 1; while (i < j) { if (s[i] != s[j]) return false; ++i; --j; } return true; }
Using For and If statement:
public bool IsPalindrome_new(string src) { bool palindrome = true; for (int i = 0; i < src.Length / 2 + 1; i++) { if (src[i] != src[src.Length - i - 1]) { palindrome = false; break; } } return palindrome; }