我实质上是想将多个项目添加到列表中,但最后所有项目的值都等于最后一个项目。
model.DocumentShapeModel = JsonConvert.DeserializeObject<List<DocumentShapeModel>>(model.Shapes);
var documentShapeModel = model.DocumentShapeModel.ToList();
for (int j = 0; j < documentShapeModel.Count; j++)
{
if (documentShapeModel[j].userId.Contains("1111"))
documentShapeModel[j].userId = string.Empty;
string[] signerList = documentShapeModel[j].userId.Split(",");
if (signerList.Length > 1)
{
var signerIdList = new List<string>();
signerIdList = model.SignerIds.ToList();
var itemToRemove = model.DocumentShapeModel.SingleOrDefault(r => r.userId == documentShapeModel[j].userId);
model.DocumentShapeModel.Remove(itemToRemove);
var shapeList = new List<DocumentShapeModel>();
for (int i = 0; i < signerList.Length; i++)
{
var shapes = new DocumentShapeModel();
shapes = documentShapeModel[j];
shapes.userId = signerList[i].Trim();
model.DocumentShapeModel.Append(shapes);
signerIdList.Add(signerList[i].Trim());
}
model.SignerIds = signerIdList.ToArray();
}
}