Advertisement
svetlyoek

Untitled

Jan 30th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace ConsoleApp150
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. while(true)
  11. {
  12. var input = Console.ReadLine();
  13.  
  14. if(input=="END")
  15. {
  16. return;
  17. }
  18. int number = 0;
  19.  
  20. char symbol = ' ';
  21. double floating = 0.0;
  22. bool isBool;
  23.  
  24. if (int.TryParse(input, out number))
  25. {
  26.  
  27. Console.WriteLine($"{number} is integer type");
  28.  
  29. }
  30. else if (char.TryParse(input, out symbol))
  31. {
  32.  
  33. Console.WriteLine($"{symbol} is character type");
  34.  
  35. }
  36. else if (double.TryParse(input, out floating))
  37. {
  38.  
  39. Console.WriteLine($"{floating} is floating point type");
  40.  
  41. }
  42. else if (bool.TryParse(input, out isBool))
  43. {
  44. if (isBool == false)
  45. {
  46. string boolean = "false";
  47. Console.WriteLine($"{boolean} is boolean type");
  48. }
  49. else
  50. {
  51. string boolean = "true";
  52.  
  53. Console.WriteLine($"{boolean} is boolean type");
  54. }
  55.  
  56. }
  57. else
  58. {
  59. Console.WriteLine($"{input} is string type");
  60. }
  61.  
  62.  
  63.  
  64.  
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement