Skip to content

Instantly share code, notes, and snippets.

@breezhang
Created February 13, 2012 15:31
Show Gist options
  • Save breezhang/1817617 to your computer and use it in GitHub Desktop.
Save breezhang/1817617 to your computer and use it in GitHub Desktop.
Enumerable Join some stuff
//need .net 4.0
var s1 = Enumerable.Range(1, 10).ToList().Select(i => new {name = i%7,sex =i,age= i*10});
var s2 = Enumerable.Range(1, 10).ToList().Select(i => new {name = i & 0xFE});
var result = s2.Join(s1, arg => arg.name, arg => arg.name, (a, b) => b).Distinct();
if(result.Any())
{
result.ToList().ForEach(obj => _show(obj.name + "/"+ obj.sex + "/" + obj.age));//+"/" + obj.b));
}
/*------result
0/7/70
2/2/20
2/9/90
4/4/40
6/6/60
--------------*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment