Skip to content

Instantly share code, notes, and snippets.

@dluciano
Last active December 10, 2023 11:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dluciano/a7a326511e38bd200a4a1066d8e41e9d to your computer and use it in GitHub Desktop.
Save dluciano/a7a326511e38bd200a4a1066d8e41e9d to your computer and use it in GitHub Desktop.
Palindrome - C#
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