Salve ragazzi, di seguito vi posto il codice che ho realizzato per calcolare tutte le possibili combinazioni di stringhe contenute nell'array denominato arrayList

codice:
Public Shared Function get_combinazioniAllCamereSub(ByRef arrayList() As List(Of String), ByRef indexJ As Integer, ByRef indexk As Integer, ByRef strTmp As String, ByRef strFinal As String) As String

        If indexJ > arrayList.Length - 1 Then
            Return strTmp & "#"
        Else
            For j As Integer = indexJ To arrayList.Length - 1

                For k As Integer = 0 To arrayList(j).Count - 1
                    strFinal = strFinal & get_combinazioniAllCamereSub(arrayList, j + 1, k, strTmp + "@" + arrayList(j)(k), strFinal)
                Next k

            Next j
        End If

        Return strFinal

    End Function

Dim arrayList(nCamere - 1) As List(Of String)

If arrayList.Length > 0 Then

            For j As Integer = 0 To arrayList(0).Count - 1

                Dim strControl As String = get_combinazioniAllCamereSub(arrayList, 1, 0, arrayList(0)(j), "")

                'strControl  contiene la combinazione che devo analizzare
            Next j

        End If
i risultati sono tutti perfetti il problema è che se supero come indice di arrayList il valore 5, aspnet mi da errore di system.out.of.memory...Il problema è la funzione get_combinazioniAllCamereSub, come posso ottimizzarla per nn avere questo problema?