Exceptions are expensive.
They are not flow control.
❌
try {
return dict[key];
} catch {
return null;
}
✅
return dict.TryGetValue(key, out var value) ? value : null;
Rule
If it can fail often → do NOT use exceptions.
Daily micro-tips for C#, SQL, performance, and scalable backend engineering.
Exceptions are expensive.
They are not flow control.
try {
return dict[key];
} catch {
return null;
}
✅
return dict.TryGetValue(key, out var value) ? value : null;
Rule
If it can fail often → do NOT use exceptions.