How to Joint elements from within the array with specified Step and the array result LINQ

Mansour_Dalir 1,676 Reputation points
2024-05-22T16:00:56.13+00:00

hi

Dim ByStep as integer=3

Dim MyArray as Integer()={2,5,4,0,0,4,24,6,5,2,5}

need Result As String()={"254","004","2465","25"}

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,868 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,642 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 114.1K Reputation points
    2024-05-22T18:39:55.04+00:00

    Maybe like this:

    Dim Result As String() =
        MyArray.
            Select(Function(v, i) New With {i, v}).
            GroupBy(Function(p) p.i \ 3).
            Select(Function(g) String.Concat(g.OrderBy(Function(p) p.i).Select(Function(p) p.v.ToString))).
            ToArray()
    

0 additional answers

Sort by: Most helpful