新添加到列表中的数据将替换 a 中的先前值list<>
。在以下代码中, listRM
包含Address
信息中的所有项目。我究竟做错了什么?
public void Assign(Rprts PrevItem, Rprts CurrentItem, List<Fields> listRM)
{
Fields field = new Fields();
field.hding = "Name :";
field.FName = PrevItem.fname;
field.LName = PrevItem.lname;
field.addrs1 = "";
field.addrs2 = "";
field.City = "";
listRM.Add(field);
field.hding = "Address :";
field.Qty = "";
field.Name = "";
field.Dept = "";
field.addrs1 = "ABC";
field.addrs2 = "XYZ";
field.City = "UVW";
listRM.Add(field);
}