Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.21 KB | None | 0 0
  1. Public Class Class1
  2.  
  3. #Region "Variables"
  4.     Private mstrName As String = String.Empty
  5.     Private mintKey As Integer
  6.     Shared mintCount As Integer
  7.     Shared mCollection As Collection
  8. #End Region
  9.  
  10. #Region "Constructor"
  11.     Public Sub New(ByVal Name As String)
  12.         mstrName = Name
  13.         mintCount += 1
  14.         mintKey = mintCount - 1
  15.         mCollection.Add(Me, mintKey.ToString)
  16.     End Sub
  17.  
  18.     Protected Overrides Sub Finalize()
  19.         mintCount -= 1
  20.         mintKey = mintCount - 1
  21.         mCollection.Remove(mintKey.ToString)
  22.         GC.Collect()
  23.     End Sub
  24. #End Region
  25.  
  26. #Region "Properties"
  27.     Public ReadOnly Property Name As String
  28.         Get
  29.             Return mstrName
  30.         End Get
  31.     End Property
  32. #End Region
  33.  
  34. #Region "Methods"
  35.     Public Shared Sub Attack()
  36.         If mintCount < 5 Then
  37.             For Each o As Object In mCollection
  38.                 Console.WriteLine(o + ": Not me!")
  39.             Next
  40.         ElseIf mintCount >= 5 Then ' made this line a little more simple for you! <3
  41.             For Each o As Object In mCollection
  42.                 Console.WriteLine(o + ": Attack! Attack! Attack!")
  43.             Next
  44.         End If
  45.     End Sub
  46. #End Region
  47. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement