Public Class Tester
Public Shared Sub Main
Dim Counter1 As New Counter
Dim Counter2 As New Counter
Console.WriteLine("Total count = " & Counter1.Count())
Console.WriteLine("Total count = " & Counter2.Count())
Console.WriteLine("Total count = " & Counter1.Count())
Console.WriteLine("Total count = " & Counter2.Count())
Console.WriteLine("Total count = " & Counter1.Count())
Console.WriteLine("Total count = " & Counter2.Count())
Console.WriteLine("Total count = " & Counter1.Count())
Console.WriteLine("Total count = " & Counter2.Count())
End Sub
End Class
Public Class Counter
Shared Data As Integer = 0
Public Function Count() As Integer
Data += 1
Return Data
End Function
End Class
Total count = 1
Total count = 2
Total count = 3
Total count = 4
Total count = 5
Total count = 6
Total count = 7
Total count = 8