Snippet: Disposable class

property value
IDE VS Code
Language C#
Title Disposable class
Shortcut c_Disposable
Description class that implements IDisposable interface

Placeholders

Identifier Tooltip Default Value
modifier Modifier(s) public
name Class name ClassName

Code

public class ClassName : IDisposable {
	private bool _disposed;

	public void Dispose() {
		Dispose(true);
		GC.SuppressFinalize(this);
	}

	protected virtual void Dispose(bool disposing) {
		if (!_disposed) {
			if (disposing) {
				throw new NotImplementedException();
			}

			_disposed = true;
		}
	}
}