What do braces after C# new statement do?

前端 未结 7 1806
孤城傲影
孤城傲影 2020-12-13 08:29

Given the code below, what is the difference between the way position0 is initialized and the way position1 is initialized? Are they equivalent?

7条回答
  •  盖世英雄少女心
    2020-12-13 08:53

    Object and collection initializers, used to initialize fields on an object.

    http://msdn.microsoft.com/en-us/library/bb384062.aspx

    They produce nearly equivalent IL. Jon Skeet has the answer on what is really going on.

提交回复
热议问题