fork download
  1. namespace Problem_11.Odd_Number
  2. {
  3. using System;
  4.  
  5. public class Program
  6. {
  7. public static void Main()
  8. {
  9. var number = int.Parse(Console.ReadLine());
  10.  
  11. while (true)
  12. {
  13. if (number % 2 == 0)
  14. {
  15. Console.WriteLine("Please write an odd number.");
  16. }
  17.  
  18. else
  19. {
  20. Console.WriteLine($"The number is: {Math.Abs(number)}");
  21. break;
  22. }
  23.  
  24. number = int.Parse(Console.ReadLine());
  25. }
  26. }
  27. }
  28. }
Runtime error #stdin #stdout #stderr 0s 135168KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Unhandled Exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: String
  at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00006] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Int32.Parse (System.String s) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Problem_11.Odd_Number.Program.Main () [0x00005] in <2d99eebf4fca4ee09403c37c0f5092a9>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
Parameter name: String
  at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x00006] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00014] in <8f2c484307284b51944a1a13a14c0266>:0 
  at System.Int32.Parse (System.String s) [0x00007] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Problem_11.Odd_Number.Program.Main () [0x00005] in <2d99eebf4fca4ee09403c37c0f5092a9>:0