CodeRush shows the Cannot yield in the body of a try block with a catch clause code issue if the yield keyword is located within the body of a try block with a catch clause.
Fix
Move the yield statement out of the try block.
Purpose
Highlights the yield statements, which would cause the Cannot yield a value in the body of a try block with a catch clause compilation error.
Example
| ||||
|
|
| ||||
|
|
本文介绍了一个C#编程中的常见问题:在带有catch子句的try块内使用yield关键字会导致编译错误。文章提供了具体的代码示例及修正方案,将yield语句移出try块来避免编译错误。


1万+

被折叠的 条评论
为什么被折叠?



