Advertisement
ss3434

TRY TO PARSE

Jan 22nd, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. using System;
  2.  
  3. 49 namespace ConsoleApp1//тип данни
  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. //стринг към доубле
  15. bool doubleTryParseIsSuccess = double.TryParse(command, out double doubleValue)
  16. bool charTryParseIsSuccess = char.TryParse(command, out char charValue); //стринг към чар
  17. bool boolTryParseIsSuccess = bool.TryParse(command, out bool boolValue);
  18. //стринг към боол
  19.  
  20. if (intTryParseIsSucceess)
  21. {
  22. Console.WriteLine($"{command} is integer type");
  23. }
  24. else if (doubleTryParseIsSuccess)
  25. {
  26. Console.WriteLine($"{command} is floating point type");
  27. }
  28. else if (boolTryParseIsSuccess)
  29. {
  30. Console.WriteLine($"{command} is boolean type");
  31. }
  32. else if (charTryParseIsSuccess)
  33. {
  34. Console.WriteLine($"{command} is character type");
  35. }
  36. else
  37. {
  38. Console.WriteLine($"{command} is string type");
  39. }
  40.  
  41. command = Console.ReadLine();
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement