Wednesday, January 30, 2013

C#/.NET Little Wonders: 5 Easy Ways to Combine Sequences

C#/.NET Little Wonders: 5 Easy Ways to Combine Sequences:

If you need to squeeze a little more performance to combine large lists or other enumerable sources, that does not contain any duplicate items, then here's what I've found in my testing:

Fastest, with no duplicates: Concat(list1).Concat(list2).Concat(list3).Concat(list4).Union(list5);

Remember, this style worked the best in my classes. Always test yours..

No comments: