4 ms·
I once attended a course on the .NET memory management and GC model taught by Jeffrey Richter, who was on the CLR team for some time. His opinion was that you s
by Analemma_ 10y ago
I once attended a course on the .NET memory management and GC model taught by Jeffrey Richter, who was on the CLR team for some time. His opinion was that you should never use "using", and that he opposed adding it to the language at all, but was overridden. At the end of the day I think that's a little excessive, but I do try to avoid "using" unless I know the surrounding object has a long lifecycle and the IDisposable utilizes a very limited resource.
- nextweek2 10y agoYou'll need to explain the reasoning behind why he doesn't want people to use using. I've not found a drawback and found it shortened my code. Only downside is the extra indentation. The original article just pointed out a basic coding flaw of having new within a loop. The using wasn't the bad part.
- scotty79 10y agoI tried to reuse entity framework context as if it was db connection and it ended in eveything working but occasionally producing bizzare errors that went away only when I created at least one context per method.