A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
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.
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:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.