Last active
December 10, 2023 11:21
-
-
Save dluciano/a7a326511e38bd200a4a1066d8e41e9d to your computer and use it in GitHub Desktop.
Palindrome - C#
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 Test | |
{ | |
public static bool Palindrome(string text){ | |
if(string.IsNullOrWhiteSpace(text)) | |
return false; | |
text = text.ToLower(); | |
for(int i = 0; i < text.Length / 2; i++){ | |
if(text[i] != text[text.Length - 1 - i]) | |
return false; | |
} | |
return true; | |
} | |
public static void Main() | |
{ | |
var text = "Eebee"; | |
var isP = Palindrome(text); | |
Console.WriteLine(text + " is " + (isP ? "" : "not ") + "Palindrome."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment