concept initialization in category c#

appears as: initialization, initialization
C# in Depth, Fourth Edition

This is an excerpt from Manning's book C# in Depth, Fourth Edition.

LINQ also brought other benefits for initialization in the form of object initializers and collection initializers. These allow you to specify a set of properties to set on a new object or items to add to a new collection within a single expression. It’s simpler to show than describe, and I’ll borrow an example from chapter 3. Consider code that you might previously have written like this:

  • Object and collection initializers make initialization simpler and more readable. They also allow initialization to occur as a single expression, which is crucial for working with other aspects of LINQ.
  • C# in Depth

    This is an excerpt from Manning's book C# in Depth.

    Figure 1.1. Evolution of the Product type, showing greater encapsulation, stronger typing, and ease of initialization over time