C# 从两个列表中获取最不匹配的值<;T>;用C语言实现LINQ#
我的名单如下:C# 从两个列表中获取最不匹配的值<;T>;用C语言实现LINQ#,c#,linq,list,C#,Linq,List,我的名单如下: public class matrix { public string Row { get; set; } public string Column { get; set; } public int Value { get; set; } } 因此,在我的主要方法中,以下两个列表具有不同的值 List<matrix> matrixList1 = new List&
public class matrix
{
public string Row { get; set; }
public string Column { get; set; }
public int Value { get; set; }
}
因此,在我的主要方法中,以下两个列表具有不同的值
List<matrix> matrixList1 = new List<matrix>();
List<matrix> matrixList2 = new List<matrix>();
List matrixList1=新列表();
List matrixList2=新列表();
现在我已经多次尝试从两个列表中查找最不匹配的数据,其中三个属性(即行、列和值)的值将使用LINQ进行更改。实际上,我正在从两个列表“matrixlist1”和“matrixlist2”中查找不匹配的值
其中(matrixlist1.Row!=matrixlist2.Row&&matrixlist1.Column!=matrixlist2.Column&&matrixlist1.Value!=matrixlist2.Value)
。你能帮我一下吗?先谢谢你 类似这样:
var uniqueItems=matrixList1.Where(l1=>!matrixList2.Any(l2=>l1.Row==l2.Row&&l1.Column==l2.Column&&l1.Value==l2.Value))
我不明白你在这里“查找最不匹配的数据”是什么意思。您是否正在查找list1
中与list2
中的条目不匹配的条目,因为行
或列
或值
不匹配?请使用左外联接。请参阅以下网页:请详细说明您正在尝试执行的操作。否,实际上我正在从两个列表“matrixlist1”和“matrixlist2”中查找不匹配的值,其中(matrixlist1.Row!=matrixlist2.Row&&matrixlist1.Column!=matrixlist2.Column&&matrixlist1.Value!=matrixlist2.Value)。否,实际上,我正在从两个列表“matrixlist1”和“matrixlist2”中查找不匹配的值,其中(matrixlist1.Row!=matrixlist2.Row&&matrixlist1.Column!=matrixlist2.Value!=matrixlist2.Value!=matrixlist2.where(l2=>等),这正是我需要的。非常感谢你。每次,我都没能回答相应的问题&这就是我没有得到正确答案的原因。无论如何,再次非常感谢你。