Dark mode switch icon Light mode switch icon

throw new DumbCodingException

1 min read

I came across the dumbest code I’ve seen in a while at work today.

try
{
    return _Collection.Length;
}
catch (NullReferenceException)
{
    return 0;
}

I found it because when debugging an asp.net page, I had enabled thrown exception breaks and this code was causing about 5 debug breaks for every page load…  Needless to say it has now been rewritten.

Originally published on by Jason Axley