c# - Compiler Requiring Return Value - Not Noticing Unconditional Exception in Called Method -
why c# compiler not smart enough in following scenario?
void throwex() { throw new exception(); } int test() { throwex(); }
...test()': not code paths return value
edit: in practice, want extract exception throwing logic separate method because i'm tired typing stuff throw new faultexception<mycustomfault>(new mycustomfault(), "cannot validate input");
it doesn't between methods; not least, method in different assembly , change without rebuilds, or virtual, extern, abstract or partial - confusing spot small number of cases.
you have throwex return "int", , then:
return throwex();
which make compiler happy. or use generics:
static t throwex<t>() {...} ... return throwex<int>();
Comments
Post a Comment