Hot to get Ienumerable Index



Hi, I got a problem. I have an excel file with a lot of info. I need to take column “A” and column “X” and I’m taking it with “Read Column” Activity than gives me an IEnumerable for each column, let’s call it variables “ColumnA” and “ColumnX”.

Now, I need to take “ColumnA” data in an ARRAY just if “ColumnX” says “True”.

I thougth to make a for each of the “ColumnA” and depending of the index of this item, take the index of “ColumnX” value to ask if it’s True and save the data in the array. BUT doesn’t work.

Let me know how to handle this.
Thank you very much



The easiest way would be to convert the 2 IEnumerables to arrays and you will be able to do this. Use the .ToArray method to convert an IEnumerable to an array.

This approach would be the easiest, in my opinion.

If you want to use the IEnumerables, however, here is some sample code for you: ienumerable.xaml (9.9 KB)

You can loop through 2 IEnumerables at the same time if you get their IENumerator , using the .GetEnumerator method

Once you obtain it you can loop through the elements using the “.MoveNext” method and you can get the current element in the collection using the Current property.

In my demo, you can see how these properties can be used to loop through 2 Ienumerables at the same time.

Also, it is a best practice to dispose the IEnumerators after you use them so I did that by using the Invoke Method.

Hope this helps.