I'm aware of technique to handle IDisposable in a traditional manner. Say, in OnStop() method of windows service I close message queue client:
if (client != null)
{
client.Dispose();
}
For the first time today I saw one guy doing that this way:
using (client)
{
client = null;
}
What is exactly happening inside his "using" or does he dispose correctly at all?
The using(){}
statement grabs a copy of the reference var so this assignment with null
is ineffective.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With