-
-
Save mikejwhitty/5dee879e6910e0189fe9246221e10dc4 to your computer and use it in GitHub Desktop.
check if string is palindrome...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(isPalindrome("Test your strings...")); | |
Console.WriteLine(isPalindrome("...sgnirts ruoy tseT")); | |
Console.WriteLine(isPalindrome("Test your strings......sgnirts ruoy tseT")); | |
} | |
private static bool isPalindrome(string input) | |
{ | |
char[] inputArray = input.ToCharArray(); | |
int length = inputArray.Length; | |
for (int b = 0, e = length-1; b < e; b++, e--) | |
{ | |
if ( inputArray[b] != inputArray[e] ) | |
{ | |
return false; | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment