Wednesday, May 25, 2011

Using Keyword.

What is using keyword?

1) Using as Directive in C# can be used for importing namespaces to your classes.

2)Another most useful advantage is it can be used in codeblocks what is does is it calls the Dispose() method automatically to release the resources and also automatically implements the try catch blocks for us.Here it is called a using statement.So the advantage is that we dont have to explicitly write a try-catch block and our code looks small.

3)using block,
If we declare any un-managed object in using block, u don't need to explicitly dispose those object.. once the block execution is over, the Dispose will be called automatically.

No comments:

Post a Comment