What happens under the hood when using array initialization syntax to initialize a Dictionary instan

Posted by Carlos Loth on Stack Overflow See other posts from Stack Overflow or by Carlos Loth
Published on 2010-05-25T21:52:33Z Indexed on 2010/05/26 21:01 UTC
Read the original article Hit count: 319

Filed under:
|

Does anyone know what C# compiler does under the hood with the following code?

dict = new Dictionary<int, string>()
{
    { 1, "value1" },
    { 2, "value2" }
}

It is not clear to if it creates the KeyValuePair instances and call the Add method, or do something more optimized. Does anyone of you know it?

© Stack Overflow or respective owner

Related posts about c#

Related posts about dictionary