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