Skip to content

Instantly share code, notes, and snippets.

@mikejwhitty
Created November 26, 2016 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikejwhitty/5dee879e6910e0189fe9246221e10dc4 to your computer and use it in GitHub Desktop.
Save mikejwhitty/5dee879e6910e0189fe9246221e10dc4 to your computer and use it in GitHub Desktop.
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