C# error “Not all code paths return a value”

后端 未结 8 1883
长发绾君心
长发绾君心 2020-12-12 06:05

I translated this part of the code from vb to c# and giving me this error message. \"Not all code paths return a value\". What is the problem? Thanks in advance.

<         


        
8条回答
  •  余生分开走
    2020-12-12 06:34

    You need to add a return statement after your catch clause!

    In case of an exception inside your try catch clause, you won't return a value. And that's exactly what your error is indicating.

提交回复
热议问题