1, two list generics use LINQ to repeat data
Code:
list<string> Lsta =Newlist<string> {"e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568" }; List<string> LSTB =Newlist<string> {"e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568","e00401501b652569" }; List<string> newlist = lsta.findall (x =!)lstb.contains (x)); foreach(varIteminchnewlist) {Console.WriteLine (item); } console.readkey ();
Console Run Results
Figure 1
Figure 1 Why this is happening and nothing is output. Below to modify the next program, see 2
2, first look at Code:
list<string> Lsta =Newlist<string> {"e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568" }; List<string> LSTB =Newlist<string> {"e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568","e00401501b652569" }; List <string> NewList = lstb.findall (x =! ) Lsta.contains (x)); foreach(varIteminchnewlist) {Console.WriteLine (item); } console.readkey ();
Look at the results again:
Figure 2
Look at the code of the bold line and figure 2 results, you must see why.
The array of a is treated as B-interval, the range of B is greater than a interval, and the public parts of a and B are removed, and the different parts are found out.
1 Results There is no data output, the reason is here.
3, in the A array in the addition of a MAC address at this time a, b two range of the same size
Code
list<string> Lsta =Newlist<string> { "e00401501b652562" ,"e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568" }; List<string> LSTB =Newlist<string> {"e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568","e00401501b652569" }; List<string> newlist = lstb.findall (x =!)lsta.contains (x)); foreach(varIteminchnewlist) {Console.WriteLine (item); } console.readkey ();
Look at the results again:
Figure 3
As shown in Figure 3 and Figure 2, the data that is not duplicated should be the e00401501b652562,e00401501b652569 two MAC addresses correctly.
How does the code adjust? See 4
4,code
list<string> Lsta =Newlist<string> {"e00401501b652563","e00401501b652562","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568" }; List<string> LSTB =Newlist<string> {"e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568","e00401501b652569" }; List<string> Listall =Newlist<string>(); List<string> Listresult =Newlist<string>(); varListunionall = Lsta.union (LSTB). (t = t);//Sort merge Data foreach(varIteminchListunionall) {Listall.add (item); } List<string> newlist = listall.findall (x =!lsta.contains (x));//to repeat, combine a new list collectionlist<string> newList2 = listall.findall (x =!)lstb.contains (x)); varUnionlist = Newlist.union (newList2). (t = t);//Sort merge Data foreach(varIteminchunionlist) {Console.WriteLine (item); } console.readkey ();
Results
5, find the duplicate data to the LINQ is not equal to remove the line.
list<string> Lsta =Newlist<string> {"e00401501b652562","e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568" }; List<string> LSTB =Newlist<string> {"e00401501b652563","e00401501b652564","e00401501b652565","e00401501b652566","e00401501b652567","e00401501b652568","e00401501b652569" }; List<string> newlist = lstb.findall (x =lsta.contains (x)); foreach(varIteminchnewlist) {Console.WriteLine (item); } console.readkey ();
Results
MAC addresses 62 and 69 have no output.
C # Two List generics use LINQ to repeat data or to get duplicate data