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

4 Likes

Thank you its working

1 Like

Hey @KarthikByggari

Can we extract a part of array? I mean is it possible to extract 3 arrays of 9 elements from an array of 27?

In your screenshot there are 16 elements in the array so can we extract two arrays of 8 elements as follows:
Array1 = {β€œA”,β€œB”,β€œC”,β€œD”,β€œE”,β€œF”,β€œG”,β€œH”}
Array2 = {β€œI”,β€œJ”,β€œK”,β€œL”,β€œM”,β€œN”,β€œO”,β€œP”}

@rahulsharma - please take a look here…

1 Like

Thanks @prasath17 that was helpful. :slight_smile:

1 Like