What is using statement versus using directive?
Interview question and answer by: Tripati_tutu
| Posted on: 10/28/2010 | Category: ASP.NET Interview questions
| Views: 1033 | | Points: 40
You can create an instance in a using statement to ensure that Dispose is called on the object when the using statement is closed or else we can say Using automatically calls the stream object’s Dispose method when the Using statement is closed. A using statement can be exited either when the end of the using statement is reached or if an exception is thrown and control leaves the statement block before the end of the statement.
The using directive has two uses:
• Create an alias for a namespace (a using alias).
• Permit the use of types in a namespace, such that, you do not have to qualify the use of a type in that namespace (a using directive).
| Alert Moderator
Found interesting? Add this to: