Skip to content

Explain the relationship between try blocks and using for iterators #45331

Open
@BillWagner

Description

@BillWagner

Type of issue

Missing information

Description

From anonymous feedback:

Please add a small note on using blocks, as there is a bit of confusion out on the Internet about this. Since using blocks translate to try blocks, can they be used inside iterator functions? Do they always get auto-disposed of after the first yield return?

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/yield

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/statements/yield.md

Document Version Independent Id

a8770d79-8ce3-d728-116c-6efc2639a0eb

Platform Id

062f3768-972a-0f62-66f6-0ac6ab840ef6

Article author

@BillWagner

Metadata

  • ID: fb91b9e6-ca8d-9169-6536-5fe342d014d8
  • PlatformId: 062f3768-972a-0f62-66f6-0ac6ab840ef6
  • Service: dotnet-csharp
  • Sub-service: lang-reference

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions