Contains
compares the object itself, you want to compare a property. Use Any
:
fileListing
.RemoveAll(i => failedFileListing.Any(fnt => i.OrigFileName == fnt.OrigFileName));
If you want to use Contains
you need to override Equals
(+ GetHashCode
):
public class FileNameTuple
{
//...
public override bool Equals(object obj)
{
if(object.ReferenceEquals(obj, this) return true;
FileNameTuple t2 = obj as FileNameTuple;
if(t2 == null) return false;
return OrigFileName == t2.OrigFileName;
}
public override int GetHashCode()
{
return (OrigFileName ?? "").GetHashCode();
}
}
Now you can compare FileNameTuple
s:
fileListing.RemoveAll(i => failedFileListing.Contains(i));