Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 536955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:52:33+00:00 2026-05-13T09:52:33+00:00

I like the C# 3 initializer syntax and use it a lot, but today

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:52:34+00:00Added an answer on May 13, 2026 at 9:52 am

    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;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently read that Java now sports initialisation blocks like the following: class C
I have created a delegated Array class like this: class LeadPartArray < DelegateClass(Array) def
I'm halfway through figuring out a solution to my question, but I have a
I've been trying to initialize a map of <ints, vector<ints> > using the new
I know how to initialize a static member that's not an integer, but I'm
While programming I have come to an unusual error. When I initialize an integer
I am using an aggregate initializer to set up a block of static data
Rookie C++ Programmer here again I'm using VC++ VS2008 and making an attempt at
guys. Here's a simple sample two-dimensional array in PL/SQL, which is working perfectly. declare
EDITED BELOW FOR UPDATES!!! Thank you for the help, please by all means point

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.