Logo 
Search:

C# FAQ

Submit Interview FAQ
Home » Interview FAQ » C#RSS Feeds

How do I use the 'using' keyword with multiple objects?

  Shared By: Oliver Evans    Date: Nov 01    Category: C#    Views: 885

Answer:

You can nest using statements, like this:

using( obj1 )
{
using( obj2 )
{
...
}
}
However consider using this more aesthetically pleasing (but functionally identical) formatting:

using( obj1 )
using( obj2 )
{
...
}

Share: 
 

Didn't find what you were looking for? Find more on How do I use the 'using' keyword with multiple objects? Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: