I am pretty new to Windows Workflow Foundation so this question may seem a little simple.
What's the major difference between Argument and Variables in a Workflow? And which one should be used in what situation.
For e.g. if I need to store some object which can be used by all activities in the workflow, and also the activites should be able to modify the object. Which one should I use - Variable or Argument?
Arguments are Input and Output from Activities (a whole workflow also counts as an Activity in WWF)
So any data put into a workflow comes in via an Argument named in the workflow as an InArgument. (everytime I write InArgumentt I could also use InOutArgument)
Any data put into an Activity comes in via an Argument named in the activity as an InAargument.
Output is the same except the Argument must be marked as Out (or In/Out)
The values in the Arguments are available inside the workflow or activity that set the argument as in InArgument
Variables only exist inside the container where they are named. So variables in a workflow are created in the workflow and are not passed in.
You can assign a workflow level variable to the InArgument of an activity by assigning the variable to an InArgument in the Properties panel for the Activity.
Variables also have scope so if you have nested workflow activities you can limit the variable to the nested workflow and not the whole workflow.
Arguments only exist in the container they were Input to. So if you want to pass an Argument from a workflow to an Activity you must add that Argument as a parameter to an InArgument in the Properties panel for the Activity.
You can output from an Activity to an Argument or variable by adding that Argument or variable as a parameter to an OutArgument in the Properties panel for the Activity.