C# 3.0 Sets, a first look
It has been a while since I blogged about C# 3.0, but this one is exciting, I heard that .net 3.5 will have support for Set operations on lists like Union, Intersect so I gave it a try and it turned out to be cool
check this out
static void Main(string[] args)
{
var setA = new List<int>{ 1, 2, 3, 4, 5, 6};
var setB = new List<int>{ 1, 3, 4, 7 , 9};
var setC = setA.Intersect(setB);
var setD = setA.Union(setB);
setC.ToList().ForEach(Console.Write);
Console.WriteLine();
setD.ToList().ForEach(Console.Write);
Console.WriteLine();
}
and also notice the influence of functional style programming on C# 3.0,