我有以下代码:
var statusCode = response.StatusCode;
switch (statusCode)
{
case ObexStatusCode.Accepted:
break;
case ObexStatusCode.BadGateway:
break;
case ObexStatusCode.BadRequest:
throw new BadRequestException();
break;
case ObexStatusCode.Conflict:
throw new ConflictException();
break;
case ObexStatusCode.Continue:
break;
case ObexStatusCode.Created:
break;
case ObexStatusCode.DatabaseFull:
break;
}
如果statusCode只有一个值,它可以正常工作。但有时它可以有2个值。据我所知,我可以这样写:
if ((statusCode & ObexStatusCode.Accepted) == ObexStatusCode.Accepted)
{
}
但如何使用SWITCH进行操作?感谢