fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. String[] values = { null, "160519", "9432.0", "16,667",
  8. " -322 ", "+4302", "(100);", "01FA", "11111", "1234", "1234-1234-1234" };
  9. foreach (var value in values) {
  10. int number;
  11.  
  12. bool result = Int32.TryParse(value, out number);
  13. if (result == true)
  14. {
  15. Console.WriteLine("This input value is definitely not valid as it is a number.");
  16. }
  17. else
  18. {
  19. Console.WriteLine("Perhaps this can be a valid input value as it could not be parsed as integer.",
  20. value == null ? "<null>" : value);
  21. }
  22. }
  23. }
  24. }
Success #stdin #stdout 0.04s 23944KB
stdin
Standard input is empty
stdout
Perhaps this can be a valid input value as it could not be parsed as integer.
This input value is definitely not valid as it is a number.
Perhaps this can be a valid input value as it could not be parsed as integer.
Perhaps this can be a valid input value as it could not be parsed as integer.
This input value is definitely not valid as it is a number.
This input value is definitely not valid as it is a number.
Perhaps this can be a valid input value as it could not be parsed as integer.
Perhaps this can be a valid input value as it could not be parsed as integer.
This input value is definitely not valid as it is a number.
This input value is definitely not valid as it is a number.
Perhaps this can be a valid input value as it could not be parsed as integer.