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重寫了一下:
復(fù)制代碼 代碼如下:
ListFileInfo> garbagePicList = new ListFileInfo>(); var query = from pic in fiAllPicList where !usedPicList.Contains(pic.Name) select pic; garbagePicList = query.ToList();