Advertisement
spasnikolov131

Untitled

Sep 24th, 2021
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Data_Type_Finder
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string input = Console.ReadLine();
  10.  
  11. string dataType = string.Empty;
  12.  
  13. while (input != "End")
  14. {
  15. if (int.TryParse(input, out _))
  16. {
  17. dataType = "integer";
  18. }
  19. else if (double.TryParse(input, out _))
  20. {
  21. dataType = "double";
  22. }
  23. else if (char.TryParse(input, out _))
  24. {
  25. dataType = "character";
  26. }
  27. else if (bool.TryParse(input, out _))
  28. {
  29. dataType = "boolean";
  30. }
  31. else
  32. {
  33. dataType = "string";
  34. }
  35.  
  36. Console.WriteLine($"{input} is {dataType} type");
  37.  
  38. input = Console.ReadLine();
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement