Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. string input = Console.ReadLine();
  8.  
  9. try
  10. {
  11. int n = Convert.ToInt32(input);
  12. string dataType = null;
  13.  
  14. Console.WriteLine($"{n} can fit in:");
  15.  
  16. if (n >= sbyte.MinValue && n <= sbyte.MaxValue)
  17. {
  18. Console.WriteLine("* sbyte");
  19. }
  20. if (n >= byte.MinValue && n <= byte.MaxValue)
  21. {
  22. Console.WriteLine("* byte");
  23. }
  24. if (n >= short.MinValue && n <= short.MaxValue)
  25. {
  26. Console.WriteLine("* short");
  27. }
  28. if (n >= ushort.MinValue && n <= ushort.MaxValue)
  29. {
  30. Console.WriteLine("* ushort");
  31. }
  32. if (n >= int.MinValue && n <= int.MaxValue)
  33. {
  34. Console.WriteLine("* int");
  35. }
  36. if (n >= uint.MinValue && n <= uint.MaxValue)
  37. {
  38. Console.WriteLine("* uint");
  39. }
  40. if (n >= long.MinValue && n <= long.MaxValue)
  41. {
  42. Console.WriteLine("* long");
  43. }
  44. }
  45. catch (Exception)
  46. {
  47. Console.WriteLine($"{input} can't fit in any type");
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement