VB.Net program to count the total created objects using a shared member
'VB.net program to count the total created objects
'using a shared member.
Module Module1
Class Sample
Shared count As Integer
Sub New()
count = count + 1
End Sub
Sub ObjectCount()
Console.WriteLine("Total objects: {0}", count)
End Sub
End Class
Sub Main()
Dim obj1 As New Sample()
Dim obj2 As New Sample()
Dim obj3 As New Sample()
obj3.ObjectCount()
End Sub
End Module
Total objects: 3
Press any key to continue . . .
Table of Contents