You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/statements/using.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,8 @@ When you declare several instances in one `using` statement, they are disposed i
37
37
38
38
You can also use the `using` statement and declaration with an instance of a [ref struct](../builtin-types/ref-struct.md) that fits the disposable pattern. That is, it has an instance `Dispose` method that's accessible, parameterless, and has a `void` return type.
39
39
40
+
A `return` inside a `using` block still guarantees disposal, the compiler rewrites it into a `try/finally`, so the resource’s `Dispose` is always called before the method actually returns.
41
+
40
42
The `using` statement can also be of the following form:
0 commit comments