title: How add 2D arrays into Arraylist?
body: <pre><code>Imports System
  Imports System.IO
  Imports System.Collections
  Module Module1
  
      Sub Main()
      Dim ColArray As New ArrayList()
  
      Dim File, Files() As FileInfo
      Dim Dir As New DirectoryInfo(&quot;C:\Users\User\Desktop\Nezavisimai\Papka2&quot;)
      Files = Dir.GetFiles(&quot;.xls*&quot;)
      For Each File In Files
  
          Dim xlApp As Excel.Application
          Dim xlBook As Excel.Workbook
          Dim xlSheet As Excel.Worksheet
  
          xlApp = CType(CreateObject(&quot;Excel.Application&quot;), Excel.Application)
          xlApp.Visible = False
          xlBook = CType(xlApp.Workbooks.Open(File), Excel.Workbook)
          xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
  
          Dim myRange As Excel.Range
          myRange = xlApp.Range(&quot;A1:C3&quot;)
          Dim myArray As Object(,)
          myArray = myRange.Value
  
          ColArray.AddRange(myArray)
          xlApp.Quit()
  
      Next
  
      Dim numRows As Long, numCols As Long, r As Long, c As Long, rT As Long
      numRows = ColArray.Item(1).GetUpperBound(0)
      numCols = ColArray.Item(1).GetUpperBound(1)
  
      Dim fArray(,) As Object, arr(,) As Object
      ReDim fArray(0 To (numRows * ColArray.Count), 0 To numCols)
  
      rT = 0
      'loop over collection and add each item to the final array
      For Each arr In ColArray
          For r = arr.GetLowerBound(0) To numRows
              rT = rT + 1
              For c = arr.GetLowerBound(1) To numCols
                  fArray(rT, c) = arr(r, c)
              Next c
          Next r
      Next arr
  
      For i As Integer = 0 To fArray.GetUpperBound(0)
          For j As Integer = 0 To fArray.GetUpperBound(1)
              Console.Write(&quot;{0} &quot;, fArray(i, j))
          Next
          Console.WriteLine()
      Next
  End Sub
  End Module
  </code></pre>
  <p>It does not work. Error. Problem with AddRange 2D arrays into Arraylist. I am getting an error saying: Different size of 2D  arrays and ArrayList.
  Dim ColArray As New ArrayList((,)) - error.
  How does it work? How to combine 2D arrays in ArrayList?</p>