C# / .NET Bug Hunt Easy +10 XP
Unhandled Exception
This crashes on invalid input.
C# / .NETFind the bug
1
string input = "abc";2
int number = int.Parse(input); The bug is on line 2
Select the correct fix
Show answer and explanation
Answer: Both A and B work
int.Parse throws FormatException on invalid input. Use TryParse which returns bool, or try/catch to handle the exception gracefully.
Hint: 'abc' can't be parsed as an integer.
What this challenge tests
Bug Hunt in C# / .NET: exceptions, parsing.