Constructor

Object and Collection Initializer in C#

The Object Initializer and Collection Initializer are similar to initialized Array and Object Constructor where we are able to set the properties of the newly created objects or multiple instances of the new object in essentially one line of code.

Object initializers are similar to the constructors that populates the properties of the newly created instances of the object.

Unlike the constructor,you can pick and choose which properties to populate in any combination .

class Address { public string street { get; set; } public string city { get; set; } }class Users { public int UserID { get; set; } public string UserName { get; set; } public

read more