Looping issue

Hi, totalEID is my Int variable, now the value of totalEID = 20. But i want to iterate the loop 20 times.Ifd i pass the variable in the loop. Why it’s shpowing me this error,


@lakshman

1 Like

@balkishan

Use While loop instead of ForEach loop.

1 Like

@balkishan

     While count < totalEID

Where count is interger variable and initialise with 1

1 Like

For Each activity is used to iterate through each item of a collection/list. In this case, you can use while statement to perform iteration using the int variable.

1 Like

@balkishan

Yes you should.

1 Like

@balkishan
Your totalEID is a single int value. For Looping you need a set (e.g., array, list, an enumerable) of values.
With following trick you can create from your totalEID a Set of e.g 20 items:
instead of totalEID just use: Enumerable.Range(0, totalEID ) assumed totalEID = 20

1 Like

In addition to that, if you still want to loop ‘n’ number of times using for loop-

For i in Enumerable.Range(0,n).ToArray()

Reference -

Regards,
Karthik Byggari

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.