C# List Copy

UserModel 略

List<UserModels> lstUser = new List<UserModels>{...}

Coyp:

  var lstUserCopy = new List<UserModels>(lstUser.ToArray());

Test1:

  lstUserCoyp.Add(new UserModels{...}); 

  lstUser.length + 1 = lstUserCoyp.length       OK!

Test2:

  lstUserCoyp[0].Birthday = DateTime.Parse("2014/12/31");

  lstUser[0] 发成变化。   ERROR!

C# List Copy

上一篇:MVC4.0中WEBAPI通过HttpContextBase获取请求参数


下一篇:Windows 10 Technical Preview初体验