Working with OutArgument in Workflow

If you want to assign a value to an OutArgument in your workflow here is something you need to keep in mind.  If your OutArgument is something simple like a value type or a string you can simply write to it directly

image

If your OutArgument is something more complex, you will have to initialize it first.  If you don’t initialize your OutArgument you will get an exception

System.InvalidOperationException was unhandled
Message=The property 'Collection' of 'AddToCollection<String>' is not initialized.
Source=System.Activities

In this workflow I’m using an OutArgument<List<string>> before using it I create a New List(Of String) to store the values

image

OutArgumentExample.zip