Advertisement
ad2bg

DifferentIntegersSize

May 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace DifferentIntegersSize
  4. {
  5.     class DifferentIntegersSize
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var s = Console.ReadLine();
  10.             var types = string.Empty;
  11.  
  12.             if (sbyte.TryParse(s, out sbyte r1)) { types += "* sbyte\n"; }
  13.             if (byte.TryParse(s, out byte r2)) { types += "* byte\n"; }
  14.  
  15.             if (short.TryParse(s, out short r3)) { types += "* short\n"; }
  16.             if (ushort.TryParse(s, out ushort r4)) { types += "* ushort\n"; }
  17.  
  18.             if (int.TryParse(s, out int r5)) { types += "* int\n"; }
  19.             if (uint.TryParse(s, out uint r6)) { types += "* uint\n"; }
  20.  
  21.             if (long.TryParse(s, out long r7)) { types += "* long\n"; }
  22.             //if (ulong.TryParse(s, out ulong r8)) { types += "* ulong\n"; }
  23.  
  24.             if (types == string.Empty) { Console.WriteLine($"{s} can't fit in any type"); }
  25.             else { Console.WriteLine($"{s} can fit in:\n{types}"); }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement