我有下面的代码。如果RecoveryRecords变量中的数据不在 ValidClaimControl 编号中,我将根据以下条件删除它。
在RecoveryRecords.Remove(s)执行该行后,它也将从记录变量中删除。我实际上需要来自记录变量的数据。
我想知道如何在记录变量中保留数据?
List<List<Field>> records = new List<List<Field>>();
List<List<Field>> RecoveryRecords = new List<List<Field>>();
//Some Logic here to populate records variable
RecoveryRecords = records;
List<string> validClaimControlNo = new List<string>();
//Some Logic here to populate validClaimControlNo variable
foreach (List<Field> s in RecoveryRecords.ToList())
{
foreach (Field f in s)
{
if (!(validClaimControlNo.Contains(f.Value)))
RecoveryRecords.Remove(s);
}
}