© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
17 replies
ApathyErr

❔ Why does this code always return False?

public static bool IsPalindrome(int x)
{
  return x.ToString().Reverse() == x.ToString();
}
static void Main(string[] args)
{
  Console.Write("Enter a number:");
  int x = Convert.ToInt32(Console.ReadLine());
  Console.Write(IsPalindrome(x));
}
public static bool IsPalindrome(int x)
{
  return x.ToString().Reverse() == x.ToString();
}
static void Main(string[] args)
{
  Console.Write("Enter a number:");
  int x = Convert.ToInt32(Console.ReadLine());
  Console.Write(IsPalindrome(x));
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Why does this function return NaN?
C#CC# / help
2y ago
why does this code not work???
C#CC# / help
3w ago
❔ Why does this code give the CS8604 warning?
C#CC# / help
4y ago
Why does this code have a Required attribute?
C#CC# / help
4y ago