I have this If statement and I would like to move them into Case-Switch
Here is my if Stataments:
if (rResponse.ErrorCode[0] == 0x20 && rResponse.ErrorCode[1] == 0x03)
ErrorMsg = "COMM_FRAME_ERROR";
if (rResponse.ErrorCode[0] == 0x20 && rResponse.ErrorCode[1] == 0x04)
ErrorMsg = "JAM";
if (rResponse.ErrorCode[0] == 0x20 && rResponse.ErrorCode[1] == 0x05)
ErrorMsg = "NO_CARD";
How can I do that?
if (rResponse.ErrorCode[0] == 0x20) {
switch(rResponse.ErrorCode[1]) {
case 0x03:
ErrorMsg = "COMM_FRAME_ERROR";
break;
case 0x04:
ErrorMsg = "JAM";
break;
case 0x05:
ErrorMsg = "NO_CARD";
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With