0% found this document useful (0 votes)
25 views1 page

C# 8.0 'using' Declaration Explained

The document discusses the 'using' declaration in C#, which allows for automatic calling of the 'Dispose' method when a variable goes out of scope. This feature was introduced in C# 8.0. An example is provided, demonstrating how to create an object using this declaration within a method.

Uploaded by

Partha Gayen
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

C# 8.0 'using' Declaration Explained

The document discusses the 'using' declaration in C#, which allows for automatic calling of the 'Dispose' method when a variable goes out of scope. This feature was introduced in C# 8.0. An example is provided, demonstrating how to create an object using this declaration within a method.

Uploaded by

Partha Gayen
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C#

‘using’ Declaration
› You can prefix "using" keyword before the local variable declaration,
What in order to call "Dispose" method when that variable goes out of
scope.
› New feature introduced in C# 8.0

Creating object

public void Method( )


How {
using ClassName referenceVariable = new ClassName( );

//do work here

} //Dispose will be called automatically here

You might also like