Tuesday, July 14, 2009

C# 3.0 Syntax of the Day

Can't believe I missed this one...


var items = new string[] { "David", "Jennifer" };


versus:


var items = new[] { "David", "Jennifer" };


Yep, that's right! "new[]" is okay. The compiler will infer the type of the array based on the type of the items within the squigglies.