Advertisement
Guest User

Untitled

a guest
Oct 4th, 2018
1,140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _10.DataTypeFinder
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. while (true)
  11. {
  12. string word = Console.ReadLine();
  13. if (word=="END")
  14. {
  15. break;
  16. }
  17. bool isBolean = bool.TryParse(word, out bool boolean);
  18. bool isInteger = int.TryParse(word, out int integer);
  19. bool isChar = char.TryParse(word, out char character);
  20. bool isDouble = double.TryParse(word, out double floating);
  21. if (isBolean)
  22. {
  23. Console.WriteLine($"{boolean.ToString().ToLower()} is boolean type");
  24.  
  25. }
  26. else if (isInteger)
  27. {
  28. Console.WriteLine($"{integer} is integer type");
  29.  
  30. }
  31. else if (isChar)
  32. {
  33. Console.WriteLine($"{character} is character type");
  34.  
  35. }
  36. else if (isDouble)
  37. {
  38. Console.WriteLine($"{floating} is floating point type");
  39.  
  40. }
  41. else
  42. {
  43. Console.WriteLine($"{word} is string type");
  44. }
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement