我是 C# 新手,正在处理现有项目。我clone
在所有数据类中都发现了这个,有人能告诉我为什么有必要这样做吗?如果我不使用克隆,有任何已知问题吗?提前致谢!
public class PreviewRequestDetails : ICloneable
{
[DataMember]
public string Address { get; set; }
........
public object Clone()
{
return new PreviewRequestDetails
{
Address = this.Address,
Email = this.Email,
Id = this.Id,
Country = this.Country,
Phone = this.Phone,
Titles = this.Titles.Select(p => p.Clone() as Title).ToList(),
CreatedBy = this.CreatedBy,
CreatedOn = this.CreatedOn,
UpdatedOn = this.UpdatedOn,
Delete = this.Delete
};
}
}