Can “using” with more than one resource cause a resource leak?

No.

The compiler will generate a separate finally block for each variable.

The spec (ยง8.13) says:

When a resource-acquisition takes the form of a
local-variable-declaration, it is possible to acquire multiple
resources of a given type. A using statement of the form

using (ResourceType r1 = e1, r2 = e2, ..., rN = eN) statement 

is precisely
equivalent to a sequence of nested using statements:

using (ResourceType r1 = e1)
   using (ResourceType r2 = e2)
      ...
         using (ResourceType rN = eN)
            statement

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)