假设我有这门课
public class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
public bool isActive { get; set; }
}
并像这样使用它:
List<Employee> Employees = new List<Employee>();
Employees.Add(new Employee { FirstName = "firstname", LastName = "lastname", isActive = true });
List<Employee> EmployeesCopy = new List<Employee>(Employees);
EmployeesCopy[0].isActive = false;
为什么更改的isActive
属性EmployeesCopy
也会修改原始列表中的属性?