Advertisement
Guest User

Data Type Finder

a guest
Jan 27th, 2020
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2.  
  3. namespace DataTypeFinder
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string input = Console.ReadLine();
  10.  
  11.             while (input != "END")
  12.             {
  13.                 bool isInteger = int.TryParse(input, out int integer);
  14.                 bool isFloating = float.TryParse(input, out float floating);
  15.                 bool isCharacters = char.TryParse(input, out char character);
  16.                 bool isBolean = bool.TryParse(input, out bool boolean);
  17.                 if (isInteger)
  18.                     Console.WriteLine($"{integer} is integer type");
  19.                 else if (isFloating)
  20.                     Console.WriteLine($"{floating} is floating point type");
  21.                 else if (isCharacters)
  22.                     Console.WriteLine($"{character} is character type");
  23.                 else if (isBolean)
  24.                     Console.WriteLine($"{input} is boolean type");
  25.                 else
  26.                     Console.WriteLine($"{input} is string type");
  27.                 input = Console.ReadLine();
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement