How to store particular array elements of an array into another array

Hi All,

I want to extract the array elements of every 7th position and store in another array.

Please help

Hi @thima take one assign activity and assign like this new array_varible = old_array(6) six means you will get 7 the position element .

Hi @thima,
1.You can do like this for storing into the other variable.
other_array_varriable =array.AsEnumerable().Skip(7).Take(array.length-1).ToArray
If you find this useful mark it as solution.If any doubts ping me.
Cheers,
Vashisht.

With array it is not possible to add items in a loop or iterative way.

Please follow these steps.

  1. Convert your array to List. Declare a variable lst of type String
    lst = New List<Of String>
    Assign Activity lst = arr.OfType(Of String).ToList

  2. Declare a new array to store every 7th element.
    arr_7 = New Array
    Assign Activity arr_7 = lst.Where(Function(x, i) i > 0 AND i Mod 7 = 0).ToArray()

arr_7 contains all 7th position elements.

Sample VB.Net code and result -

Regards,
Karthik Byggari

3 Likes

Thank you its working

1 Like