Files
Introduktion-till-CSharp/10.8-Palindrome/Palindrome.cs
2018-02-22 23:01:00 +01:00

21 lines
416 B
C#

using System;
class Palindrome {
public static void Main() {
string test = "Sallad i Dallas";
test = test.ToLower();
Console.WriteLine("Ar texten \"{0}\" ett Palindrom?: {1}", test, isPalindrome(test));
}
static bool isPalindrome(string input) {
int length = input.Length;
for (int i = 0; i < length / 2; i++) {
if (input[i] != input[length - i - 1])
return false;
}
return true;
}
}