Check if word entred is a palindrome or not !
A palindrome is a word, phrase, number or sequence of words that reads the same backwards as forwards.
Exemples : WOW, 12321, Anna, ...
Programme return true or false.
using System;
class Palindrome
{
public static bool Check(string word){
for(int i = 0; i < word.Length; i++)
{
word = word.ToUpper();
if(i >= word.Length /2)
{
break;
}
if(word[i] != word[word.Length - 1 - i])
{
return false;
}
}
return true;
}
}
namespace Solution {
using NUnit.Framework;
using System;
// TODO: Replace examples and use TDD development by writing your own tests
[TestFixture]
public class SolutionTest
{
[Test]
public void MyTest()
{
Assert.AreEqual(true, Palindrome.Check("MOM"));
Assert.AreEqual(true, Palindrome.Check("kAyaK"));
Assert.AreEqual(true, Palindrome.Check("123454321"));
}
}
}