Using the Foreach activity
In this task, we will use the Foreach
activity to traverse a person-type object.
How to do it...
Create a Workflow Console Application project:
Create a new Workflow Console Application project and name it
UsingForeachActivity
. We can refer to the following screenshot:Create a
Person
class file:Add a new class file to the project, name the file
Person.cs
, fill the file with the following code, and save and build the project.namespace UsingForeachActivity { public class Person { public string Name { get; set; } public int Age { get; set; } public Person(string name, int age) { this.Name = name; this.Age = age; } public override string ToString() { return "Name:" + this.Name + " " + " Age:" + this.Age; } } }
Import the
UsingForeachActivity
namespace to the workflow:In the bottom of workflow designer, click Imports and import the
UsingForeachActivity
namespace...