Advertisement
joro_thexfiles

1. Data Type Finder

May 28th, 2019
1,070
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _1___Data_Type_Finder
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string command = Console.ReadLine();
  10.  
  11.             while (command != "END")
  12.             {
  13.                 bool intTryParseIsSucceess = int.TryParse(command, out int intValue);
  14.                 bool doubleTryParseIsSuccess = double.TryParse(command, out double doubleValue);
  15.                 bool charTryParseIsSuccess = char.TryParse(command, out char charValue);                
  16.                 bool boolTryParseIsSuccess = bool.TryParse(command, out bool boolValue);
  17.  
  18.                 if (intTryParseIsSucceess)
  19.                 {
  20.                     Console.WriteLine($"{command} is integer type");
  21.                 }
  22.                 else if (doubleTryParseIsSuccess)
  23.                 {
  24.                     Console.WriteLine($"{command} is floating point type");
  25.                 }
  26.                 else if (boolTryParseIsSuccess)
  27.                 {
  28.                     Console.WriteLine($"{command} is boolean type");
  29.                 }
  30.                 else if (charTryParseIsSuccess)
  31.                 {
  32.                     Console.WriteLine($"{command} is character type");
  33.                 }
  34.                 else
  35.                 {
  36.                     Console.WriteLine($"{command} is string type");
  37.                 }
  38.  
  39.                 command = Console.ReadLine();
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement