Palindromic Number in C# (original) (raw)
Published on 18 February 2025 (Updated: 18 February 2025)
Welcome to the Palindromic Number in C# page! Here, you'll find the source code for this program as well as a description of how the program works.
Current Solution
using System;
public class PalindromicNumber
{
public static void Main(string[] args)
{
try
{
long verifyInput = long.Parse(args[0]);
if (verifyInput >= 0)
{
Console.WriteLine(palindrome(args[0]));
}
else
{
Console.WriteLine("Usage: please input a non-negative integer");
}
}
catch
{
Console.WriteLine("Usage: please input a non-negative integer");
}
}
public static string palindrome(string numString)
{
char[] digits = numString.ToCharArray();
int backCount = digits.Length - 1;
for (int i = 0; i < digits.Length; i++)
{
if (digits[i] != digits[backCount])
{
return "false";
}
else
{
backCount--;
}
}
return "true";
}
}
Palindromic Number in C# was written by:
- maple-johnson
If you see anything you'd like to change or update, please consider contributing.
How to Implement the Solution
No 'How to Implement the Solution' section available. Please consider contributing.
How to Run the Solution
No 'How to Run the Solution' section available. Please consider contributing.