How to Replace an Arraylist

104 16
    • 1). Create the ArrayList variable. A variable needs initializing before you can use an ArrayList in your code. The following code shows you how to create the variable:

      Dim arrList as New ArrayList()

    • 2). Add some values to the ArrayList. ArrayLists can contain hundreds and even thousands of values. In this example, two values are assigned to the list:

      arrList.Add("one")
      arrList.Add("two")

    • 3). Replace the ArrayList by copying its content to a one-dimensional array. The following code creates a one-dimensional array and copies the ArrayList to the variable:

      Dim oneDimArray() as String
      arrList.CopyTo(oneDimArray)

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.