I like the C# 3 initializer syntax and use it a lot, but today while looking in Reflector, the following came up:
var binding = new WSHttpBinding
{
ReaderQuotas = { MaxArrayLength = 100000 },
MaxReceivedMessageSize = 10485760
};
At first I thought it was a mistake, but it does compile! Guess I am still learning new stuff all the time. :)
From what I can tell, it sets the MaxArrayLength
property of the ReaderQuotas
property of the WSHttpBinding
.
Does this syntax create a new ReaderQuotas
object and then set the property, or does it assume the property to be initialized already? Is this the general way one would use to initialize 'child' properties?
I do find the syntax a bit confusing...