Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:29:35+00:00 2026-06-17T08:29:35+00:00

Please have a look at the code below: Imports System.Data.Common Imports System.Data.SqlClient Imports System.Data.OracleClient

  • 0

Please have a look at the code below:

Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Data.OracleClient

Public Class clsParameterValues
    Implements IDisposable

    Private paramValues(0) As DbParameter

    Public Function AssignParameterValues(ByVal strParameterName As String, ByVal strParameterValue As String, ByVal intDatabaseType As Integer) As Integer
        Dim intArrayBound As Integer

        intArrayBound = UBound(paramValues)
        If intArrayBound > 0 Then
            ReDim paramValues(intArrayBound)
        End If

        If intDatabaseType = 1 Then

            paramValues(intArrayBound) = New SqlParameter(strParameterName, strParameterValue)
        ElseIf intDatabaseType = 2 Then
            paramValues(intArrayBound) = New OracleParameter(strParameterName, strParameterValue)
            'paramValues(intArrayBound) = New OracleParameter(":" & strParameterName, OracleType.Int32)
            'paramValues(intArrayBound).Value = strParameterValue
        End If
        Return intArrayBound
    End Function

    Public Function getParameterValues() As DbParameter()
        Return paramValues
    End Function

    Public Sub Dispose() Implements IDisposable.Dispose
        Erase paramValues
        paramValues = Nothing
    End Sub

End Class

The webpage function looks like this:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim objParameterValues As New clsParameterValues
                Using objParameterValues
                    'Use the objParameterValues class here.
                End Using
                objParameterValues=nothing
            End Using
End Sub

I am using IDisposable.Dispose to erase the array before setting it to Nothing. I believe this is bad practice because the Array class does not implement IDisposable. Is it even necessary to erase an array and set it to Nothing? (Does the garbage collector deal with this?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:29:36+00:00Added an answer on June 17, 2026 at 8:29 am
    Public Sub Dispose() Implements IDisposable.Dispose
        Erase paramValues
        paramValues = Nothing
    End Sub
    

    The Erase statement dates from old versions of Basic, the kind where manual memory management was useful. No more, memory management is automatic in .NET. It is still supported for compatibility reasons. All it does is set the array reference to Nothing. So your code is equivalent to:

    Public Sub Dispose() Implements IDisposable.Dispose
        paramValues = Nothing
        paramValues = Nothing
    End Sub
    

    So no point to it. You should never implement IDisposible to set a variable to Nothing, that’s not the interface’s contract. A disposed object may never be used again. So no point in setting the array reference to null since that doesn’t actually do anything to the real array object on the garbage collected heap. I cannot otherwise see a scenario where you would want to help, any clsParameterValues object should have a limited lifetime. It just isn’t useful anymore when you null the array reference.

    Just remove the IDisposable implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please have a look at the code below: public class MyGridFragment extends Fragment{ Handler
Please have a look at the code below: public class Vehicle 'Not very well
Please have a look at the code below: Class A package generalscenarios; public class
please have a look at the following code import java.util.ArrayList; import java.util.List; public class
Please have a look at the code below (excerpt from a C# book): public
Please have a look at the code below: import string from collections import defaultdict
Please have a look on the code below .. <div id=click_me>Save</div> <div id=blocks_sortable> <div
Could you please have a look at my code below. #!C:\Perl\bin\perl.exe use strict; use
Please have a look at the following code namespace Funny { class QuesionsAndAnswers {
Please have a look at the code below and explain to me why there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.