Under what circumstances is try..catch{} OK ? - TechRepublic
General discussion
November 8, 2007 at 02:42 PM
tony hopkinson

Under what circumstances is try..catch{} OK ?

by tony hopkinson . Updated 18 years, 8 months ago

Bettter yet if this was in the setter method of a public property, with an event handler in it?

.NET 2.0 set the binding source property (listBox, Combox etc..), this fires SelectedItemChanged.
Put any code in the event handler that throws an unhandled exception, and the component f’ing swallows it.

try
{
bs = value;
}
catch
{
displayvalue = “”;
}

I know how to get round it, there’s even a comment in there about why teh code looks strange.

What I can’t figure out is why some one at Redmond thought this was the way to go.

What am I missing.?

This discussion is locked

All Comments