我创建了两个列表,例如,
var list = new List<KeyValuePair<string, string>>();
list.Add(new KeyValuePair<string, string>("1", "abc"));
list.Add(new KeyValuePair<string, string>("2", "def"));
list.Add(new KeyValuePair<string, string>("3", "ghi"));
var list2 = new List<KeyValuePair<string, string>>();
list.Add(new KeyValuePair<string, string>("1", "abc"));
list.Add(new KeyValuePair<string, string>("2", "def"));
list.Add(new KeyValuePair<string, string>("3", "ghi"));
list.Add(new KeyValuePair<string, string>("4", "jkl"));
var unmatchedlist= new List<KeyValuePair<string, string>>();
如何比较两个列表。现在我需要list.Add(new KeyValuePair("4", "jkl")); (因为它不在 firstlist 中,但它在 secondlist 中有用)在 unmatchedlist 中?