Initializer syntax

No, that doesn’t create new objects unless you use = new SomeType {...}:

var binding = new WSHttpBinding
{
    ReaderQuotas = new XmlDictionaryReaderQuotas { MaxArrayLength = 100000 },
    MaxReceivedMessageSize = 10485760
};

Your example shows the initializer syntax for setting properties of existing sub-objects. There is also a similar syntax for calling “Add” methods on collections.

Your code is broadly comparable to:

var binding = new WSHttpBinding();
binding.ReaderQuotas.MaxArrayLength = 100000;
binding.MaxReceivedMessageSize = 10485760;

Leave a Comment