Wednesday, December 18, 2013

gotta love the Select Lambda

var myList = new List<int>();
foreach (KeyValuePair<int, int> x in existingAssets)
{
   myList.Add(x.Key);
}
var myArray = myList.ToArray();

 
 

What is above may merely become...

var myArray = existingAssets.Select(x => x.Key).ToArray();

No comments:

Post a Comment