title: .NET Array with Multiple Data Types
body: <p>I'm trying to create a function that essentially returns an array with the following structure:
  (String, String, Integer)</p>
  
  <p>At first, I was using a SortedList(Of String, SortedList(Of String,Integer)), but it seems like a huge waste since I don't need an array for the latter of the data. Now I'm thinking either a Rectangular Array or a DataTable, but I don't know how to define the Rectangular Array to use multiple types and I don't know how fast the DataTable will be at runtime.</p>
  
  <p>The function will be used quite frequently as a class function, so the quicker, the better.
  Here's a snippet of the code at hand:</p>
  
  <pre><code>
  
      Public Function GetDirectoryUsagePktTool(ByVal EIAFilePath As String, Optional ByVal PocketCount As Integer = 120) As SortedList(Of String, SortedList(Of String, Integer))
          'Tracks the usage of all tools currently loaded in the machine against all tools in a specified directory
          '   ordered from least used to most used.
          If Not IO.File.Exists(EIAFilePath) Then
              'Handle invalid filepath
              Throw New ApplicationException("{ToolStatus}GetDirectoryUsagePktTool: EIAFilePath doesn't exist")
          End If
          Dim EIADirectory As String = EIAFilePath.Remove(EIAFilePath.LastIndexOf("\"))
          'Get all Tool ID's with all of their FilePaths and Usage Counts per File
          Dim dtl As SortedList(Of String, SortedList(Of String, Integer)) = GetDirectoryToolList(EIADirectory, EIAFilePath.Remove(0, EIAFilePath.LastIndexOf("\") + 1))
          'Get all Tool ID's currently loaded in each (associated with) Pocket ID
          Dim pl As SortedList(Of String, String) = GetPocketList(PocketCount)
          'Return object
          Dim dupl As New SortedList(Of String, SortedList(Of String, Integer))
  
          'Counter for Total Usage count
          Dim cntr As Integer
          'Enumerate through each Pocket ID
          For Each Pocket As String In pl.Keys
              'Reset Total Usage count
              cntr = 0
  
              'Verify existence of Tool ID in directory search
              If Not IsNothing(dtl(Pocket)) Then
                  'Enumerate through File Paths using Pocket's Tool ID
                  For Each FilePath As String In dtl(pl(Pocket)).Keys
                      'Count Tool ID Usage
                      cntr += dtl(pl(Pocket))(FilePath)
                  Next
                  'Return object's Tool ID and Usage values
                  Dim tu As New SortedList(Of String, Integer)
                  'Probably not necessary, but ensure no overwriting or appended usage to Return Object
                  If IsNothing(dupl(Pocket)) Then
                      'Add reference of Pocket No. to Tool Group No and Total Count
                      '   (Pocket ID, (Tool ID, Usage))
                      tu.Add(pl(Pocket), cntr)
                      dupl.Add(Pocket, tu)
                  End If
              End If
          Next
  
          Return dupl
      End Function
  
  </code></pre>
  
  <p><b>EDIT:</b> Forgot to mention that code must be compatible with .NET 2.0 and earlier due to OS constraints.</p>
  
  <p><b>Solution:</b>
  As suggested, I created a new Structure and returned it as an array since I need all references of the Pocket ID to it's subsequent Tool ID and usage. The new structure as follows:</p>
  
  <pre><code>
      Structure PocketTools
          Public PocketID As String
          Public ToolGroupID As String
          Public UsageCount As Integer
      End Structure
  </code></pre>
  
  <p>The declaration of the return object:</p>
  
  <pre><code>
          'Return object
          'Dim dupl As New SortedList(Of String, SortedList(Of String, Integer))
          Dim dupl() As PocketTools
  </code></pre>
  
  <p>The addition to the return object</p>
  
  <pre><code>
                      'Add reference of Pocket No. to Tool Group No and Total Count
                      '   (Pocket ID, (Tool ID, Usage))
                      If IsNothing(dupl) Then
                          ReDim dupl(0)
                      Else
                          ReDim Preserve dupl(dupl.Length)
                      End If
                      dupl(dupl.Length - 1).PocketID = Pocket
                      dupl(dupl.Length - 1).ToolGroupID = pl(Pocket)
                      dupl(dupl.Length - 1).UsageCount = cntr
  
                      'tu.Add(pl(Pocket), cntr)
                      'dupl.Add(Pocket, tu)
  </code></pre>