Description

Adds an item to an existing collection.



Attributes

Misc

  • Collection - The name of the list where the item would be added.

  • DisplayName - Renames the activity.

  • Item - The item to be added to the collection.

  • TypeArgument - The type assigned to the collection where the item would be added.


Example

  1. Create a List<String> variable and name it fruits.
  2. Add an Assign activity inside the initial Sequence.
  3. In the Assign To field, add the fruits variable. 
  4. In the Assign Value field, write new List(Of String) since its default value is null.
  5. After the Assign activity, add an Add To Collection activity. 
  6. In the Add To Collection Collection field under Attributes, add the fruits variable.
  7. In the Add To Collection Item field, write "apple".
  8. After the Add To Collection activity, add a Write Line activity.
  9. In the Write Line Text field, write fruits(0).ToString.
  10. After the Write Line activity, add your second Add To Collection activity.
  11. In the Add To Collection Collection field under Attributes, add the fruits variable.
  12. In the Add To Collection Item field, write "pear".
  13. After your second Add To Collection activity, add your second Write Line activity.
  14. In the Write Line Text field, write fruits(1).ToString. 

    The use case should look as the following screenshot:



This should be the result in the Output panel: