Not all code paths return a value - where?

前端 未结 7 1197
我在风中等你
我在风中等你 2021-01-26 06:03

I have the following C# code. For reasons I won\'t go into, this is the required way of localising.

My problem is, I cannot for the life of me figure out what path is no

7条回答
  •  清歌不尽
    2021-01-26 06:29

    To prevent mistakes or puzzles like this, you better not do both of this (below) , as there is no single logical flow anymore when you:

    • Maintain a retVal variable, together with
    • Multiple uses of the return statement.

    Choose one solution:

    • only return a retVal variable, or
    • return a default at the bottom of the function.

提交回复
热议问题