dotnet / dotnet/vblang

Add scoped variables as an alternative to nested Using

Open
#387 22 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

This is another recent C# feature that I've always hoped to bring from C++.
(See [using declarations](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#using-declarations))
```
Using a = F1()
Using b = F2()
Using c = F3()
...
```
Instead of:
```
Using a = F1()
Using b = F2()
Using c = F3()

End Using
End Using
End Using
```

The idea is that a, b, and c are Disposed when the variables go out of scope. It avoids the need to nest Using statements.

I can't see any way to add this enhancement to the existing Using keyword in VB, but maybe a different keyword would be even more clear.

Scoped a = F1()
Scoped b = F2()
Scoped c = F3()

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.