“并非所有代码路径都返回值”。请解释一下这个错误。 [英] "Not all code paths return a value". Please explain about this error.

查看:666
本文介绍了“并非所有代码路径都返回值”。请解释一下这个错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

并非所有代码路径都返回值。请解释一下这个错误。

解决方案

这种错误通常发生在你的代码扩展时(使用if-else或switch case)然后从中返回值一些条件,但不是全部。



这是编译器错误CS0101,你可以阅读更多关于它 here [ ^ ]。他们有一个样本可以解释错误。


简单。错误建议你确切的问题。

你有一个函数,你可能没有在if循环中返回任何值或返回值。

来解决它检查以下内容/>
1.将函数返回更改为VOID(如果没有返回内容)

2.在结束函数之前给变量名返回关键字


< blockquote>在你的方法中,如果你的方法返回一个值,那么错误显示从方法返回你的数据仍然有一些可能的方法。



你可以给我发现这种错误的代码部分。我将标记你可能离开的方式。


"Not all code paths return a value". Please explain about this error.

解决方案

This kind of error generally occurs when you are branching out your code (using if-else or switch case) and then returning values from some of the conditions but not all.

This is the compiler error CS0101 and you can read more about it here[^]. They have a sample that should explain the error to you as well.


Simple. Error suggest you exact problem.
You have a function in which you may have not return any value or return value in if loop.
to resolve it check following things
1. change the function return to VOID (if you does not return something)
2. give return keyword with variable name before end function


In your method if your method returning a value then, The error shows that there are still some possible ways missing for returning your data from method.

You can give me code portion where you find this kind of error. I will mark possible ways you left.


这篇关于“并非所有代码路径都返回值”。请解释一下这个错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆