Cause of Error CS0161: not all code paths return a value
The simple reason is that the compiler has to be able to statically verify that all execution flow paths end up with a return statement (or an exception). Let’s look at your code, it contains: Some variables controlling a while loop A while loop, with the return statement embedded No return statement after the loop … Read more