C sharp notes

From Helpful
Jump to: navigation, search
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)
These are primarily notes
It won't be complete in any sense.
It exists to contain fragments of useful information.


using is used for two things. The one you know about is importing references into the current namespace.

The other is syntactic sugar that that helps dispose of some resources as soon as possible instead of at the next garbage collection. You use this as a scope outside which the explicitly listed objects will be Dispose()d (using only works on IDisposable objects).

It's mostly useful to be strict about limited resources, and to avoid forgetting to Dispose yourself. Consider, for example, ADO adapters.

See also