0Pricing
C# Academy · Lesson

Collection Builders

Support collection expressions in custom types.

Custom Types in Collection Expressions

Collection expressions are not limited to built-in types. With the [CollectionBuilder] attribute, your own type can be created from [...] syntax.

The CollectionBuilder Attribute

You apply [CollectionBuilder(typeof(Factory), "Create")] to your collection type. It names a static factory method the compiler calls to build instances.

All lessons in this course

  1. Collection Expression Syntax
  2. The Spread Element
  3. Target Typing Collections
  4. Collection Builders
← Back to C# Academy