Replies: 4 comments
-
relates to #451 |
Beta Was this translation helpful? Give feedback.
-
Small correction: you don't have to initialize the variable, this is valid code: ISomething thing;
using(var disposable = GetDisposable())
{
thing = disposable.GetThing();
}
thing.Consume(); |
Beta Was this translation helpful? Give feedback.
-
This doesn't appeal to me. It's unclear to which scope the declaration should escape. Also, I don't feel this helps readability. |
Beta Was this translation helpful? Give feedback.
-
A subset of the problems this is trying to solve may be solvable by introducing string text = using (var sr = new StreamReader(path)) => sr.ReadToEnd(); where I've taken the liberty to use the string five = lock (gate) => dictionary[5]; |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Scenario: When using the
using(IDisposable)
pattern to acquire something, you often need to declare variables right before, forcing you to specify the type and initialize it.With the following construct, you would save one line, and avoid having to describe the variable type.
Beta Was this translation helpful? Give feedback.
All reactions