Skip to content

Instantly share code, notes, and snippets.

@Hafthor
Created August 7, 2022 04:53
Show Gist options
  • Save Hafthor/faa2ae8714b91579205a441de9ea7ec1 to your computer and use it in GitHub Desktop.
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.
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