.NET object creation, whats faster?

后端 未结 4 625
醉酒成梦
醉酒成梦 2020-12-04 00:26

IS there a difference between those 2 ways of object creation?

new MyClass() { Id = 1, Code = \"Test\" };

or

MyClass c = ne         


        
4条回答
  •  清歌不尽
    2020-12-04 00:45

    They are the same. But we all prefer the first one, it's more readable and clearer, isn't it?

提交回复
热议问题