Skip to content

Commit

Permalink
#42112 Updated yield.md (#42560)
Browse files Browse the repository at this point in the history
#42112 updated yield.md document to mention its not allowed inside try, catch and finally blocks

#42112
  • Loading branch information
Roshni-Gandhi authored Sep 11, 2024
1 parent 4053b73 commit 5c312c8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docs/csharp/language-reference/statements/yield.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ You can't use the `yield` statements in:
- methods with [in](../keywords/method-parameters.md#in-parameter-modifier), [ref](../keywords/ref.md), or [out](../keywords/method-parameters.md#out-parameter-modifier) parameters
- [lambda expressions](../operators/lambda-expressions.md) and [anonymous methods](../operators/delegate-operator.md)
- [unsafe blocks](../keywords/unsafe.md). Before C# 13, `yield` was invalid in any method with an `unsafe` block. Beginning with C# 13, you can use `yield` in methods with `unsafe` blocks, but not in the `unsafe` block.
- `yield return` and `yield break` can not be used in [try](../statements/exception-handling-statements.md), [catch](../statements/exception-handling-statements.md) and [finally](../statements/exception-handling-statements.md) blocks.

## Execution of an iterator

Expand Down

0 comments on commit 5c312c8

Please sign in to comment.