Description
Clears all of the items within a collection.
Attributes
Misc
Collection - The name of the list where all of the items would be cleared.
DisplayName - Renames the activity.
TypeArgument - The type assigned to the collection.
Example
- Create a List<String> variable and name it fruits.
- Add an Assign activity inside the initial Sequence.
- In the Assign To field, add the fruits variable.
- In the Assign Value field, write new List(Of String) since its default value is null.
- After the Assign activity, add an Add To Collection activity.
- In the Add To Collection Collection field under Attributes, add the fruits variable.
- In the Add To Collection Item field, write "apple".
- Add your seconds Add To Collection activity.
- In the second Add To Collection Collection field under Attributes, add the fruits variable.
- In the Add To Collection Item field, write "pear".
- Create a String variable and name it item.
- After the second Add To Collection activity, add a For Each activity.
- In the For Each Values field, add the fruits variable.
- Inside the For Each activity, add a Write Line activity.
- In the Write Line Text field, add the item variable.
- After the For Each activity, add a Clear Collection activity.
- In the Clear Collection Collection field, add the fruits variable. This would clear all the items inside the specified collection.
The use case should look as the following screenshot:
After execution, the added items in the collection should be cleared.