C# compiler error: “not all code paths return a value”

You’re missing a return statement. When the compiler looks at your code, it’s sees a third path (the else you didn’t code for) that could occur but doesn’t return a value. Hence not all code paths return a value. For my suggested fix, I put a return after your loop ends. The other obvious spot – adding an else that had a return value to the if-else-if – … Read more

C# compiler error: “not all code paths return a value”

You’re missing a return statement. When the compiler looks at your code, it’s sees a third path (the else you didn’t code for) that could occur but doesn’t return a value. Hence not all code paths return a value. For my suggested fix, I put a return after your loop ends. The other obvious spot – adding an else that had a return value to the if-else-if – … Read more

C# compiler error: “not all code paths return a value”

You’re missing a return statement. When the compiler looks at your code, it’s sees a third path (the else you didn’t code for) that could occur but doesn’t return a value. Hence not all code paths return a value. For my suggested fix, I put a return after your loop ends. The other obvious spot – adding an else that had a return value to the if-else-if – … Read more