我想处理未定义的httpStatusCode,我使用Enum.IsDefined()方法,但是如果返回false,我不知道该怎么办。 真的我想返回HttpResponseMessage并想为StatusCode属性设置值,如果该方法返回true,则将int值转换为HttpStatusCode枚举,但是当它返回false时我不知道该怎么办... >
var currentStatusCode = HttpContext.Current.Response.StatusCode;
HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
if (Enum.IsDefined(typeof(HttpStatusCode), currentStatusCode))
{
httpResponseMessage.StatusCode = (HttpStatusCode)currentStatusCode;
}
else
{
//here is my problem
httpResponseMessage.StatusCode = ???
}