C# - Intersect and Except in Linq form
Something the intersect and except won't be enough for some comparisons. we will have to dig in for some particular type of values like ids, name, etc. Below is an example of this.
Intersect in linq form-
A.Intersect(B) => gives stuff in both A and B
var intersect = A.Where(x => B.Select(y => y.Id).Contains(x.Id)).ToList();
Intersect in linq form-
A.Intersect(B) => gives stuff in both A and B
var intersect = A.Where(x => B.Select(y => y.Id).Contains(x.Id)).ToList();
Except in linq form-
A.Except(B) => gives stuff in A and NOT B
var intersect = A.Where(x => !B.Select(y => y.Id).Contains(x.Id)).ToList();
A.Except(B) => gives stuff in A and NOT B
var intersect = A.Where(x => !B.Select(y => y.Id).Contains(x.Id)).ToList();
Best Pendrive Under 1000
ReplyDeleteawesome! I really appreciate the amazing work you have been doing. and in fact, this article was so amazing that I couldn't stop myself from sharing it with my blog readers.
ReplyDeleteI have mentioned you in one of my recent blog posts here:
click here
would you mind if I ask you to check it out and share it with your fans and followers?
If you share it, I'll be highly grateful for your kind act. If not I'll still appreciate your work, no hard feelings.
Thanks!
Regards,
Spiritual Teja
spiritual information
click here
Download Video Player | Windows Media Player | Best Media Player
ReplyDelete