Simplified Collection initialization
问题 While initializing WF4 activities we can do something like this: Sequence s = new Sequence() { Activities = { new If() ..., new WriteLine() ..., } } Note that Sequence.Activities is a Collection<Activity> but it can be initialized without the new Collection() . How can I emulate this behaviour on my Collection<T> properties? 回答1: Any collection that has an Add() method and implements IEnumerable can be initialized this way. For details, refer to Object and Collection Initializers for C#. (The