Link to home
Start Free TrialLog in
Avatar of altariamx2003
altariamx2003Flag for Mexico

asked on

how to dispose a custom class in vb

I have this class

Public Class misdatos
#Region " properties ..."

    Public Class myParamCar1
        Public Alfa As Double
        Public Eta As Double
        Public Mw7P As Double
        Public Z7P As Double
        Public Sg7P As Double
        Public Cf As Double
        Public Kw As Double
        Public Ja As Double
        Public Ya As Double

        Public Nscn As Integer
        Public Banderascn As Integer
        Public Metdesdob As Integer
        Public n As Integer
        Public metSg As Integer
        Public metTb As Integer
        Public metCriticas As Integer
        Public metTc As Integer
        Public metPc As Integer
        Public metomega As Integer
        Public ieq As Integer

    End Class
    Private _ParamCar1 As New misdatos.myParamCar1
    Public Property ParamCar1() As misdatos.myParamCar1
        Get
            Return _ParamCar1
        End Get
        Set(ByVal value As misdatos.myParamCar1)
            _ParamCar1 = value
        End Set
    End Property

    Private _nombre As String
    Public Property nombre() As String
        Get
            Return _nombre
        End Get
        Set(ByVal value As String)
            _nombre = value
        End Set
    End Property
    Private _ib As Integer
    Public Property ib() As Integer
        Get
            Return _ib
        End Get
        Set(ByVal value As Integer)
            _ib = value
        End Set
    End Property
    Private _solcarac As Integer
    Public Property solcarac() As Integer
        Get
            Return _solcarac
        End Get
        Set(ByVal value As Integer)
            _solcarac = value
        End Set
    End Property


    Private _solenvolv As Integer
    Public Property solenvolv() As Integer
        Get
            Return _solenvolv
        End Get
        Set(ByVal value As Integer)
            _solenvolv = value
        End Set
    End Property

    Private _solcce As Integer
    Public Property solcce() As Integer
        Get
            Return _solcce
        End Get
        Set(ByVal value As Integer)
            _solcce = value
        End Set
    End Property

    Private _soldle As Integer
    Public Property soldle() As Integer
        Get
            Return _soldle
        End Get
        Set(ByVal value As Integer)
            _soldle = value
        End Set
    End Property

    Private _c7mas As Double
    Public Property c7mas() As Double
        Get
            Return _c7mas
        End Get
        Set(ByVal value As Double)
            _c7mas = value
        End Set
    End Property

    Private _peso_molecular_c7mas As Double
    Public Property peso_molecular_c7mas() As Double
        Get
            Return _peso_molecular_c7mas
        End Get
        Set(ByVal value As Double)
            _peso_molecular_c7mas = value
        End Set
    End Property

    Private _densidad_relativa_c7mas As Double
    Public Property densidad_relativa_c7mas() As Double
        Get
            Return _densidad_relativa_c7mas
        End Get
        Set(ByVal value As Double)
            _densidad_relativa_c7mas = value
        End Set
    End Property

    Private _temp_yacimiento As Double
    Public Property temp_yacimiento() As Double
        Get
            Return _temp_yacimiento
        End Get
        Set(ByVal value As Double)
            _temp_yacimiento = value
        End Set
    End Property

    Private _h As Double
    Public Property h() As Double
        Get
            Return _h
        End Get
        Set(ByVal value As Double)
            _h = value
        End Set
    End Property

    Private _a As Double
    Public Property a() As Double
        Get
            Return _a
        End Get
        Set(ByVal value As Double)
            _a = value
        End Set
    End Property

    Private _n As Integer
    Public Property n() As Integer
        Get
            Return _n
        End Get
        Set(ByVal value As Integer)
            _n = value
        End Set
    End Property

    Private _matriz_envolvente(,) As Double
    Public Property matriz_envolvente() As Double(,)
        Get
            Return _matriz_envolvente
        End Get
        Set(ByVal value As Double(,))
            _matriz_envolvente = value
        End Set
    End Property
    Private _TbPbTrPr(,) As Double
    Public Property TbPbTrPr() As Double(,)
        Get
            Return _TbPbTrPr
        End Get
        Set(ByVal value As Double(,))
            _TbPbTrPr = value
        End Set
    End Property

    Private _matriz_carac(,) As Double
    Public Property matriz_carac() As Double(,)
        Get
            Return _matriz_carac
        End Get
        Set(ByVal value As Double(,))
            _matriz_carac = value
        End Set
    End Property

    Private _matriz_carac_despues(,) As Double
    Public Property matriz_carac_despues() As Double(,)
        Get
            Return _matriz_carac_despues
        End Get
        Set(ByVal value As Double(,))
            _matriz_carac_despues = value
        End Set
    End Property

    Private _npcomp As Double
    Public Property npcomp() As Double
        Get
            Return _npcomp
        End Get
        Set(ByVal value As Double)
            _npcomp = value
        End Set
    End Property

    Private _comp_iniciales As New List(Of Double)
    Public Property comp_iniciales() As List(Of Double)

        Get
            Return _comp_iniciales
        End Get
        Set(ByVal value As List(Of Double))
            _comp_iniciales = value
        End Set
    End Property

    Private _psaturacion_general As Double
    Public Property psaturacion_general() As Double
        Get
            Return _psaturacion_general
        End Get
        Set(ByVal value As Double)
            _psaturacion_general = value
        End Set
    End Property

    Private _nscn As Double
    Public Property nscn() As Double
        Get
            Return _nscn
        End Get
        Set(ByVal value As Double)
            _nscn = value
        End Set
    End Property

    Private _Npseudos As Double
    Public Property Npseudos() As Double
        Get
            Return _Npseudos
        End Get
        Set(ByVal value As Double)
            _Npseudos = value
        End Set
    End Property

    Private _Tablacar(,) As Double
    Public Property Tablacar() As Double(,)
        Get
            Return _Tablacar
        End Get
        Set(ByVal value As Double(,))
            _Tablacar = value
        End Set
    End Property

    Private _matriz1(,) As Double
    Public Property matriz1() As Double(,)
        Get
            Return _matriz1
        End Get
        Set(ByVal value As Double(,))
            _matriz1 = value
        End Set
    End Property

    Private _matriz2(,) As Double
    Public Property matriz2() As Double(,)
        Get
            Return _matriz2
        End Get
        Set(ByVal value As Double(,))
            _matriz2 = value
        End Set
    End Property

    Private _soreide As New List(Of String)
    Public Property soreide() As List(Of String)

        Get
            Return _soreide
        End Get
        Set(ByVal value As List(Of String))
            _soreide = value
        End Set
    End Property

    Private _dens As New List(Of String)
    Public Property dens() As List(Of String)

        Get
            Return _dens
        End Get
        Set(ByVal value As List(Of String))
            _dens = value
        End Set
    End Property

    Private _pendiente As New List(Of String)
    Public Property pendiente() As List(Of String)

        Get
            Return _pendiente
        End Get
        Set(ByVal value As List(Of String))
            _pendiente = value
        End Set
    End Property

    Private _mi As New List(Of String)
    Public Property mi() As List(Of String)

        Get
            Return _mi
        End Get
        Set(ByVal value As List(Of String))
            _mi = value
        End Set
    End Property

    Private _kij(,) As Double
    Public Property kij() As Double(,)
        Get
            Return _kij
        End Get
        Set(ByVal value As Double(,))
            _kij = value
        End Set
    End Property

    Private _kbij(,) As Double
    Public Property kbij() As Double(,)
        Get
            Return _kbij
        End Get
        Set(ByVal value As Double(,))
            _kbij = value
        End Set
    End Property

    Private _TcPcWZ(,) As Double
    Public Property TcPcWZ() As Double(,)
        Get
            Return _TcPcWZ
        End Get
        Set(ByVal value As Double(,))
            _TcPcWZ = value
        End Set
    End Property

    Private _TcPcWZ_cce(,) As Double
    Public Property TcPcWZ_cce() As Double(,)
        Get
            Return _TcPcWZ_cce
        End Get
        Set(ByVal value As Double(,))
            _TcPcWZ_cce = value
        End Set
    End Property

    Private _K1(,) As Double
    Public Property K1() As Double(,)
        Get
            Return _K1
        End Get
        Set(ByVal value As Double(,))
            _K1 = value
        End Set
    End Property

    Private _K2(,) As Double
    Public Property K2() As Double(,)
        Get
            Return _K2
        End Get
        Set(ByVal value As Double(,))
            _K2 = value
        End Set
    End Property
#End Region
End Class

Open in new window


when I need it I add a new object using this class like this:
Dim objeto1 As New misdatos

And I start to work with the properties of that object.

I would like to know how to implement a dispose to my class
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

There's nothing special going on in that class...

Just let the variable reference go out of scope, or set it to Nothing, and it will be garbage collected automatically.
Avatar of altariamx2003

ASKER

just with nothing???

ok let me try it
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
CG.Collect() ':)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Although we see a lot a people suggesting to call GC.Collect, this is very bad advice.

Microsoft advise against this in most circumnstances. You will see that warning in many places on MSDC, such as this blog: http://blogs.msdn.com/b/ricom/archive/2003/12/02/40780.aspx.

You should let the GC do his own job.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks a lot guys

this was really helpfull