Returns the number of times Increment() has been called on this instance
Syntax
Visual Basic (Declaration) | |
---|
Public ReadOnly Property InstanceCount As Integer |
C# | |
---|
public int InstanceCount {get;} |
Example
Library/Library.Test/TestUsageCounter.cs
C# | Copy Code |
---|
using (UsageCounter counter = new UsageCounter("some global name"))
{
Assert.AreEqual(0, counter.InstanceCount);
counter.Increment();
Assert.AreEqual(1, counter.InstanceCount);
counter.Increment();
Assert.AreEqual(2, counter.InstanceCount);
using (UsageCounter copy = new UsageCounter("some global name"))
Assert.AreEqual(0, copy.InstanceCount);
counter.Decrement();
Assert.AreEqual(1, counter.InstanceCount);
counter.Decrement();
Assert.AreEqual(0, counter.InstanceCount);
} |
VB.NET | Copy Code |
---|
Using counter As New UsageCounter("some global name")
Assert.AreEqual(0, counter.InstanceCount)
counter.Increment()
Assert.AreEqual(1, counter.InstanceCount)
counter.Increment()
Assert.AreEqual(2, counter.InstanceCount)
Using copy As New UsageCounter("some global name")
Assert.AreEqual(0, copy.InstanceCount)
End Using
counter.Decrement()
Assert.AreEqual(1, counter.InstanceCount)
counter.Decrement()
Assert.AreEqual(0, counter.InstanceCount)
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also