System.Activities.Statements.ForEach<System.Type>
- For Each activity is used to step through arrays, lists, data tables or other types of collections, so that iteration through the data can be done with processing each piece of information individually.
Properties
ย ย ย Misc
- DisplayName (String) โ To set a meaningful name according to the user.
- TypeArgument (Type) โ Select/Browse the datatype of the data which needs to be processed.
- Values (InArgument<IEnumerable<Type>>) โDefine the data variable of arrays/lists/data tables/other types of collections.
Example
To use a For Each activity, create an automation that goes through each element of an array of integers and write the array length and each element in the Output panel.
- Create a sequence.
- Create an array of String variables, StringArray.
- In the Default field, type the string values, such as {โAnilโ,โKrishanโ,โMohitโ,โJyotiโ,โCheenaโ}
- Add a For Each
- In the Values field, add the StringArray
- In the Body section of the For Each activity, add a WriteLine
- In the Text field, type โArray Length isโ + Length.ToString+ โand contains string element โ + item.ToString
- This expression is used to write the total number of array elements and each element of the array in the Output panel