-
Notifications
You must be signed in to change notification settings - Fork 1
IDisposable
Mario Gutierrez edited this page Jan 7, 2017
·
1 revision
If a type implements IDisposable
you can use a using
scope to automatically dispose the resource after leaving the scope.
Example without using
.
FileInfo fh = new FileInfo("somefile.txt");
FileStream fs = fh.OpenRead();
// Do stuff.
fs.Close();
Example with using
.
FileInfo fh = new FileInfo("somefile.txt");
using (FileStream fs = fh.OpenRead())
{
// Do stuff.
}
- Abstract Classes
- Access Modifiers
- Anonymous Methods
- Anonymous Types
- Arrays
- Attributes
- Console I/O
- Constructors
- Const Fields
- Delegates
- Enums
- Exceptions
- Extension Methods
- File IO
- Generics
- Interfaces
- Iterators
- LINQ
- Main
- Null Operators
- Parameters
- Polymorphism
- Virtual Functions
- Reflection
- Serialization
- Strings
- Value Types
- "Base" Keyword
- "Is" and "As"
- "Sealed" Keyword
- nameof expression