0

I have a string array A where I store some values for instance A(1) = "a,b,c" A(2)="1,2" etc. From that array I am creating subarrays using A(1).split(",") and I have

dim subArr1() as string = {"a","b","c"}
dim subArr2() as string = {"1","2"}
etc

Now, I want to create a new two-dimensional array

dim all()() as string = {subArr1, subArr2, ...}

The initial array is created dynamically and could be have 2, 5, or whatever number of items. So I could have any number of subArrays (subArrX) Any idea how to deal with that? I am writing in vb.net 2013

Thank you

2
  • No, this {subArr1, subArr2, .... } I want to be created dynamically
    – Makis
    Commented Sep 12, 2014 at 12:35
  • 1
    look up 'jagged arrays'
    – jbutler483
    Commented Sep 12, 2014 at 12:36

1 Answer 1

1

You could use this little LINQ query:

Dim A As String() = {"a,b,c", "1,2"}
Dim parts As IEnumerable(Of String()) = From str In A Select str.Split(","c)
Dim all()() As String = parts.ToArray()

Now the array contains two arrays, the first contains "a","b" and "c" and the second contains "1" and "2".

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.