CSharpTest.Net
Dispose() Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Bases Namespace > Disposable Class > Dispose Method : Dispose() Method

Glossary Item Box

disposes of the object if it has not already been disposed

Syntax

Visual Basic (Declaration) 
Public Overloads Sub Dispose() 
C# 
public void Dispose()

Example

Library/Library.Test/TestDisposable.cs

C#Copy Code
MyDisposable o = new MyDisposable();
using (o)
{
    Assert.AreEqual(0, o._disposedCount);
    o.Dispose();
    Assert.AreEqual(1, o._disposedCount);
    o.Dispose();
    Assert.AreEqual(1, o._disposedCount);
}
Assert.AreEqual(1, o._disposedCount);
VB.NETCopy Code
Dim o As New MyDisposable()
Using o
    Assert.AreEqual(0, o._disposedCount)
    o.Dispose()
    Assert.AreEqual(1, o._disposedCount)
    o.Dispose()
    Assert.AreEqual(1, o._disposedCount)
End Using
Assert.AreEqual(1, o._disposedCount)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys