Why does copy of the List still change properties in the original List using C#

后端 未结 6 1675
不知归路
不知归路 2021-01-21 02:49

Lets say I have this class

public class Employee
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public bool isActive {          


        
6条回答
  •  滥情空心
    2021-01-21 03:39

    because by using new List(Employees); will give you the new instance of List but not the objects contained in the list. You should consider cloning of objects contained in the list also , use Binary Serialization to serialize object graph.

提交回复
热议问题