<> schreef in bericht
news: oups.com...
> In most of the case,there is a "break" after every "case" in switch
> statement, poor coders have to write "break" explicitly again and
> again,and the worse is that sometimes someone forget to do that.So why
> don't the designers make it a default state? if sometimes someone
> prefer his switch statement without a break,he can achieve it by
> duplicating code for once.
This is why:
switch (type)
{
case COMMAND_RC5:
case COMMAND_RC5_STRING:
case COMMAND_RC6_MODE_0:
buf = new byte[4];
buf[0] = info;
contentIndex = 1;
break;
case COMMAND_RC5_EXTENDED:
case COMMAND_CDI:
case COMMAND_RC6_MODE_2A:
buf = new byte[5];
buf[0] = info;
contentIndex = 1;
break;
case COMMAND_RC6_MODE_1A:
case COMMAND_RC6_MODE_5:
case COMMAND_RC6_MODE_6:
buf = new byte[3 + content.length];
buf[0] = info;
buf[1] = (byte) (1 + content.length);
contentIndex = 1;
break;
case COMMAND_RC6_MODE_1B:
buf = new byte[3 + content.length];
buf[0] = info;
buf[1] = (byte) (content.length >>

;
buf[2] = (byte) content.length;
contentIndex = 3;
break;
default:
return null;
}