Wednesday, April 20, 2011

Extended List<> functions

I was working on a web part one day and tried to use List<string> to store a projected field of list items. Because the projected filed might be duplicated in the list, I need to do a distinct. But the List object in System.Collections.Generic doesn’t have that function available. After doing some research, I found that it’s the System.Linq which extends the distinct function along with other useful functions. What you need to do is to add System.Linq in the using statement and you get all the extended functions.

No comments: