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
|