Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- namespace Demo
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string message = "";
- bool isGood = false;
- try
- {
- sbyte digit = sbyte.Parse(input);
- message += "* sbyte\r\n";
- isGood = true;
- }
- catch (Exception)
- {
- }
- try
- {
- byte digit = byte.Parse(input);
- message += "* byte\r\n";
- isGood = true;
- }
- catch (Exception)
- {
- }
- try
- {
- short digit = short.Parse(input);
- message += "* short\r\n";
- isGood = true;
- }
- catch (Exception)
- {
- }
- try
- {
- ushort digit = ushort.Parse(input);
- message += "* ushort\r\n";
- isGood = true;
- }
- catch (Exception)
- {
- }
- try
- {
- int digit = int.Parse(input);
- message += "* int\r\n";
- isGood = true;
- }
- catch (Exception)
- {
- }
- try
- {
- uint digit = uint.Parse(input);
- message += "* uint\r\n";
- isGood = true;
- }
- catch (Exception)
- {
- }
- try
- {
- long digit = long.Parse(input);
- message += "* long\r\n";
- isGood = true;
- }
- catch (Exception)
- {
- }
- if (isGood)
- {
- Console.WriteLine($"{input} can fit in:");
- Console.WriteLine($"{message}");
- }
- else
- {
- Console.WriteLine($"{input} can't fit in any type");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment