开发者

C# Compare two ulong lists and subtract extraneous ulong's from the unprotected one

I have two lists of Ulongs:

The first list is a list of ulongs , the second is a (larger) list of ulongs that should be protected.

I want to somehow compare the two lists, and remove any ulongs that the f开发者_如何学编程irst list has that the protected list does not have (sort of garbage collection I guess).

What would be the recommended way to handle this?


What you are after is intersection.

var source = Enumerable.Range(1, 10);
var protectedSet = Enumerable.Range(9, 4);
var result = protectedSet.Intersect(source);

Which would result in:

source:

1
2
3
4
5
6
7
8
9
10

protectedSet:

9
10
11
12

result intersection:

9
10
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜