Hello All,
i have defined an array by using assign activity,
numbers = {1,2,3,4,5,6,7,8,9,10}
then in next assign activity,
takewhileArray = numbers.TakeWhile(Function(x) x Mod 2=0).ToArray
But in output its giving takewhileArray as empty, ideally, it should give {2,4,6,8,10}
Am i missing anything?
What is the error in my expression?
mkankatala
(Mahesh Kankatala)
March 8, 2024, 10:43am
2
Hi @NILESH.BOT369
Try the below one,
- Assign -> numbers = {1,2,3,4,5,6,7,8,9,10}
- Assign -> takewhileArray = numbers.AsEnumerable().Where(Function(X) CInt(X) Mod 2 = 0).ToArray()
Check the below image for better understanding,
Output -
Hope it helps!!
1 Like
lrtetala
(Lakshman Reddy)
March 8, 2024, 10:44am
3
Hi @NILESH.BOT369
numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
takewhileArray = numbers.Where(Function(x) x Mod 2 = 0).ToArray
1 Like
ppr
(Peter Preuss)
March 8, 2024, 10:46am
4
This HowTo gives an introductory overview of the partition Operators: Skip, Take, SkipWhile, TakeWhile
Introduction
The partition operators are used to fetch a particular subset from a set of items. The returned subset is formed by the contiguous items that are matching the provided condition.
Skip / Take Operator
The Skip Operator will omit the subsequent items from the given start for a given length and will return the remaining items
The Take Operator will return the subsequent items fr…
TakeWhile will stop, when the condition is not matched the firstTime. Therefore above use case is e.g. a filter case which can be done with the Where LINQ Operator
1 Like
mkankatala
(Mahesh Kankatala)
March 8, 2024, 10:49am
5
I have made few changes in the above reply… @NILESH.BOT369
Please, do consider the above one.
Thank you,
Works perfect…!!!
1 Like
mkankatala
(Mahesh Kankatala)
March 8, 2024, 10:50am
7
It’s my pleasure… @NILESH.BOT369
Happy Automation!!
Works fine, thank you for the reply…
1 Like
Ohh, got it, thank you,
Will go through tutorial shared by you,
Appreciate your help…
system
(system)
Closed
March 11, 2024, 10:52am
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.