ListFileInfo> garbagePicList = new ListFileInfo>(); for (int k = 0; k fiAllPicList.Length; k++) { bool found = false; for (int l = 0; l usedPicList.Count; l++) { if (fiAllPicList[k].Name == usedPicList[l].ToString()) { found = true; } } if (!found) { garbagePicList.Add(fiAllPicList[k]); } }
今天用LINQ重写了一下:
复制代码 代码如下:
ListFileInfo> garbagePicList = new ListFileInfo>(); var query = from pic in fiAllPicList where !usedPicList.Contains(pic.Name) select pic; garbagePicList = query.ToList();