Question How to Refreash an array list

Joined
Aug 28, 2008
Messages
13
Programming Experience
Beginner
Hi all
Can anyone tell me how to refreash an array;
I mean lets assume an array with some values.
Now I just want to clear all the contents of array by clicking a button.
That button will have the code like array.refreash....something like that I dont know.

Pls reply me

Thanks:D
 
Arrays can be cleared by calling Array.Clear() method, which will empty the values in the array.

for example

VB.NET:
Public Class Form1
     Dim aryInts() as Integer

     Public Sub LoadForm(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
          'fills the array with 5 values
          aryInts = new Integer() {12,23,34,45,56}
     End Sub
     Private Sub ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ClearButton.Click
          'clears the values of the array, the array still has a length of 5
          If aryInts IsNot Nothing
               Array.Clear(aryInts,0,aryInts.Length)
          End If
     End Sub

End Class
 
Be very careful. Array.Clear is something that you should rarely have to use. Maybe it's appropriate in your case but most likely it's not. What exactly are you trying to achieve? What does this array contain? What does the data represent? There's a very good chance that you shouldn't be using an array at all, but rather a collection.
 
Back
Top