السلام عليكم ورحمة الله
شباب ممكن مساعدتكم انا عندي كائن واريد انهائة عن طريق Dispose Method ( امسحه من الذاكرة ) ولكني بصراحة مو عارف ايش اكتب داخل هذه ال Method حتى اتخلص من هذا الكائن انا قمت باضافتها الى الكلاس التابع لهذا الكائن ولكني لم اعرف كيف استخدمها لاني ما فهمت ما هي ال managed objects و ال unmanaged objects اي مساعدة في شرح هذه الطريقة واكون ممنون لكم
Module mybox
Public Class Box : Implements IDisposable
Public length As Double
Private disposedValue As Boolean = False ' To detect redundant calls
' IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
' TODO: free other state (managed objects).
End If
' TODO: free your own state (unmanaged objects).
' TODO: set large fields to null.
End If
Me.disposedValue = True
End Sub
#Region " IDisposable Support "
' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(ByVal disposing As Boolean) above.
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
Sub Main()
Dim Box1 As Box = New Box
End Sub
End Module