A
alunharford
When I'm coding in Java, I might write the following (contrived) code:
boolean b = SomeMethod();
switch (b) {
case true:
return 1;
case false:
return 0;
default:
throw new InternalError();
}
InternalError indicates that something has gone massively wrong with
either the compiler or the virtual machine.
In C#, the avaliability of enums means that this seems more vital.
enum Foobar {
ONE,
TWO,
THREE
}
....
Foobar foobar = SomeMethod();
switch (foobar) {
case Foobar.ONE:
return 1;
case Foobar.TWO:
return 2;
case Foobar.THREE:
return 3;
default:
//What do I put here?
}
I could just change case "Foobar.THREE:" to "default:", but that
reduces readability.
I've been looking for an equivalent of InternalError in C#, but can't
find one in the standard. What do other people do in a situation like
this?
Alun Harford
boolean b = SomeMethod();
switch (b) {
case true:
return 1;
case false:
return 0;
default:
throw new InternalError();
}
InternalError indicates that something has gone massively wrong with
either the compiler or the virtual machine.
In C#, the avaliability of enums means that this seems more vital.
enum Foobar {
ONE,
TWO,
THREE
}
....
Foobar foobar = SomeMethod();
switch (foobar) {
case Foobar.ONE:
return 1;
case Foobar.TWO:
return 2;
case Foobar.THREE:
return 3;
default:
//What do I put here?
}
I could just change case "Foobar.THREE:" to "default:", but that
reduces readability.
I've been looking for an equivalent of InternalError in C#, but can't
find one in the standard. What do other people do in a situation like
this?
Alun Harford