Created
August 7, 2022 04:53
-
-
Save Hafthor/faa2ae8714b91579205a441de9ea7ec1 to your computer and use it in GitHub Desktop.
For making a list of disposable items. Useful since you can using wrap the list create and add disposable items to it, like FileStreams.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DisposableList<T> : List<T>, IDisposable where T : IDisposable { | |
public void Dispose() { | |
foreach (var i in this) i.Dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment