Skip to content

Instantly share code, notes, and snippets.

@mikejwhitty mikejwhitty/is-palindrome.cs Secret
Created Nov 26, 2016

Embed
What would you like to do?
check if string is palindrome...
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
You can’t perform that action at this time.