Hi all,
I'm quite new to VB .NET, so please excuse this very basic questions.
I developed the last few years in Borland Delphi and while some things are quite similar, I'm not sure how to release classes and objects correctly. Hopefully you guys can help me.
My questions are:
1. How to release a simple object, e.g. ArrayList. Currently I use the following code:
In Borland Delphi I would call the Free method (objList.Free), but there is no Free method in VB. Do I release the ArrayList correctly?
2. How to release a class?
I create and release the class in the following way:
Is this correct?
I would really appreciate if somebody could help me.
Thanks a lot for your help,
Marco
I'm quite new to VB .NET, so please excuse this very basic questions.
I developed the last few years in Borland Delphi and while some things are quite similar, I'm not sure how to release classes and objects correctly. Hopefully you guys can help me.
My questions are:
1. How to release a simple object, e.g. ArrayList. Currently I use the following code:
VB.NET:
Private Sub LoadData
Dim objList As ArrayList
' create object
objList = New ArrayList
' do something with the list
' release object
objList = Nothing
End Sub
2. How to release a class?
VB.NET:
Public Class DataImport
' Import Log
Private m_ImportLog As TextFile
' Constructor
Public Sub New()
' Create objects
m_ImportLog = New TextFile("C:\IMPORT.TXT")
End Sub
' Destructor
Protected Overrides Sub Finalize()
' Release objects
m_ImportLog = Nothing
End Sub
End Class
VB.NET:
Private Sub StartDataImport
Dim objDataImport As DataImport
objDataImport = New DataImport
' do something
' release object
objDataImport = Nothing
End Sub
I would really appreciate if somebody could help me.
Thanks a lot for your help,
Marco
Last edited: