Here’s another interesting piece of code I’ve just dug up in a C# application I’m reviewing.
If you can come up with a bright idea about what those try/catch blocks are supposed to do, you’ve got more imagination than me… 😉
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | class Foo { private int bar; // ...snip... public int GetNewBar() { int ret = 0; lock (this) { try { bar++; ret = bar; } catch { try { bar++; ret = bar; } catch {} } } return ret; } // ...snip... } |