C# - What's wrong with this code? - #1
Many months ago, I did a TechEd talk entitled "What's wrong with this code?". I've decided to re-target those snippets into blog posts. If you were at the talk, this may be boring, though I'll try to add a little anecdotal information in my answers.
Here's the plan:
- I post the snippet
- You comment on what's wrong with it
- I post my answer, and any comments that I like
- Repeat until I run out of snippetts.
Here's the snippet:
switch (s) {
case "a":
try {
HitA();
}
catch (Exception e) {
throw e;
}
break;
case "b":
try {
HitB();
}
catch (Exception e) {
throw e;
}
break;
}
What's wrong with this code?