C# / .NET Bug Hunt Easy +10 XP
Null Reference
This throws NullReferenceException.
C# / .NETFind the bug
1
string name = null;2
Console.WriteLine(name.Length); The bug is on line 2
Select the correct fix
Show answer and explanation
Answer: Add null check before accessing Length
Calling .Length on a null string throws NullReferenceException. Always check for null or use null-conditional operator (name?.Length).
Hint: What happens when you call methods on null?
What this challenge tests
Bug Hunt in C# / .NET: null-safety, exceptions.