possible to populate a collection in its constructor?

  • Thread starter Thread starter KJ
  • Start date Start date
K

KJ

Is there some way to achieve something this (without calling the Add
method of the collection)?:

NameValueCollection nvc = new NameValueCollection() {"foo"="bar",
"a"="b"};

-Thanks
 
KJ,

No, I don't believe there is. This would require some work on the
compiler's part to recognize that syntax.

You will have to use the Add method ultimately to add the name/value
pairs.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top