处理以下情况的首选方法是什么:
switch (numberOfActualBytes)
{
case 1: return something1;
case 2: return something2;
case 3: return something3;
case 4: return something4;
}
我肯定知道numberOfActualBytes
由于使用过的合同在范围内1-4
。
我应该如何编写不会导致not all code paths return a value
错误的代码?
我怀疑我应该在这个函数的末尾或 in 中抛出一些异常default switch case
,但可能有更好的解决方案。