Will Dispose() be called in a using statement with a null object?
Is it safe to use the using statement on a (potentially) null object? Consider the following example: class Test { IDisposable GetObject(string name) { // returns null if not found } void DoSomething() { using (IDisposable x = GetObject(“invalid name”)) { if (x != null) { // etc… } } } } Is it guaranteed … Read more