Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.VisualBasic;
- namespace MathUtility
- {
- // Module for identifying palindromic numbers.
- public static class Palindrome
- {
- // Function for reversing string entries.
- public static string Reverse(string value)
- {
- // Returns the reversed string
- return Strings.StrReverse(value);
- }
- // Function for converting a numeric value to String.
- public static string IntToString(long value)
- {
- // Returns a string of the numeric value.
- return System.Convert.ToString(value);
- }
- // Function for checking if the number is palindromic.
- public static bool IsPalindrome(long value)
- {
- // Selects the valid case.
- switch (true)
- {
- case object _ when value == Reverse(IntToString(value)):
- {
- // Returns true.
- return true;
- }
- default:
- {
- // Returns false.
- return false;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment