I have a string as input and have to break the string in two substrings. If the left substring equals the right substring then do some logic.
How can I do this?
protected bool CheckIfPalindrome(string text)
{
if (text != null)
{
string strToUpper = Text.ToUpper();
char[] toReverse = strToUpper.ToCharArray();
Array.Reverse(toReverse );
String strReverse = new String(toReverse);
if (strToUpper == toReverse)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
Use this the sipmlest way.