Ray's Asp.net Blog
Answers and code snippets from ASP.NET projects (Webforms/MVC/Classic ASP)
Pages
Event registration app with QR/Paypal
Home
Monday, March 21, 2011
How to find out common element(s) in two generic list by LINQ, LINQ Set Operations
int
[] twos = { 2, 4, 6, 8, 10 };
int
[] threes = { 3, 6, 9, 12, 15 };
// 6
var
intersection = twos.Intersect(threes);
// 2, 4, 8, 10
var
except = twos.Except(threes);
// 2, 4, 7, 8, 10, 3, 9, 12, 15
var
union = twos.Union(threes);
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment