Using the “clear” method vs. New Object

前端 未结 5 1967
有刺的猬
有刺的猬 2020-12-05 17:13

In the .NET framework, many of the System.Collection classes have Clear methods on them. Is there a clear advantage on using this versus replacing the reference

5条回答
  •  心在旅途
    2020-12-05 17:52

    That would depends maybe on how large your collection object is. I think when you say new it will create the original size of the object, clear would just clear the content but the size would still be the same.

提交回复
热议问题