Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- try
- {
- int n = Convert.ToInt32(input);
- string dataType = null;
- Console.WriteLine($"{n} can fit in:");
- if (n >= sbyte.MinValue && n <= sbyte.MaxValue)
- {
- Console.WriteLine("* sbyte");
- }
- if (n >= byte.MinValue && n <= byte.MaxValue)
- {
- Console.WriteLine("* byte");
- }
- if (n >= short.MinValue && n <= short.MaxValue)
- {
- Console.WriteLine("* short");
- }
- if (n >= ushort.MinValue && n <= ushort.MaxValue)
- {
- Console.WriteLine("* ushort");
- }
- if (n >= int.MinValue && n <= int.MaxValue)
- {
- Console.WriteLine("* int");
- }
- if (n >= uint.MinValue && n <= uint.MaxValue)
- {
- Console.WriteLine("* uint");
- }
- if (n >= long.MinValue && n <= long.MaxValue)
- {
- Console.WriteLine("* long");
- }
- }
- catch (Exception)
- {
- Console.WriteLine($"{input} can't fit in any type");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement