Why is an Add method required for { } initialization?

前端 未结 9 2137
渐次进展
渐次进展 2021-02-10 18:54

To use initialization syntax like this:

var contacts = new ContactList
{
    { \"Dan\", \"dan.tao@email.com\" },
    { \"Eric\", \"ceo@google.com\" }
};
<         


        
9条回答
  •  攒了一身酷
    2021-02-10 19:13

    Not an answer, strictly speaking, but if you want to know what sort of things influenced the design of collection initialisers then you'll probably find this interesting:

    • What is a collection? [straight from the Horse's mouth Mads Torgersen]

提交回复
热议问题