Welcome to SpellCoder Sign in | Join | Help

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,
kick it on DotNetKicks.com
Published Tuesday, July 03, 2007 7:41 PM by Mohammed Hossam
Filed Under:

Comments

# re: C# 3.0 Sets, a first look

Wednesday, July 04, 2007 4:43 AM by F Quednau
Yeah, those functions appeared a while ago in F#. Pretty useful they are. I like the ForEach calls...didn't know you can do currying that way in C# 3.0 ... great stuff!

# re: C# 3.0 Sets, a first look

Thursday, July 05, 2007 10:26 AM by gaurav kalra
really cool ...
actually i like the way ForEach calls are made..

actually the butter of functional style programming makes this language more powerful..
Anonymous comments are disabled