How to convert a jagged array to a one-dimensional array in VB.NET

1 Answer

0 votes
Imports System
Imports System.Linq

Public Class Program
    Public Shared Sub Main()
        Dim jaggedArray As String()() = {
			New String() {"a", "b", "c", "d"}, 
			New String() {"e", "f"}, 
			New String() {"g", "h", "i"}}
        
		Dim result = jaggedArray.SelectMany(Function(s) s).Cast(Of Object)().ToArray()
        
		Console.Write(String.Join(", ", result))
    End Sub
End Class


' run:
'
' a, b, c, d, e, f, g, h, i
'

 



answered Mar 13, 2025 by avibootz
...