Skip to content

A C# Pill to demonstrate that there is no functional difference between a 'try-finally' block, a 'using' block and a 'using' declaration.

License

Notifications You must be signed in to change notification settings

CSharp-Pills-15mg/Using-vs-Try-Finally

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

using vs try-finally

Pill Category

Language (C#)

Description

Manually call Dispose

If an object implements the IDiposable interface, it is, usually, a good practice to manually call its Dispose method as soon as the application does not need that object anymore. There are two main ways to do this:

  • explicitly - Actually call the Dispose method. Most suggested in a try-finally block.
  • implicitly - Use a using block or a using declaration.

Question

  • Is there a functional difference between the using block, the using declaration and a try-finally block?

Donations

If you like my work and want to support me, you can buy me a coffee:

ko-fi

About

A C# Pill to demonstrate that there is no functional difference between a 'try-finally' block, a 'using' block and a 'using' declaration.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Languages