Tip Of the Day - Remove Duplicate Items from a List(Of T) (or a List of whatever the hell you want)

20. September 2009

If you need to remove duplicates from a from a collection that implements IEnumerable without iterating through or overriding the .equals method you can do the following:


Dim Cars As New List(Of String)(New String() {"Blue", "Red", "Yellow", "Red", "Black", "Blue"})
Cars = Cars.Distinct().ToList()

Your list can be of anything you want. Strings, objects etc.. you can just for duplicates with the Distinct().ToList() method.

Code Snippets, Tip of the Day, VB.NET , ,

Tip of the Day

18. June 2009

In asp.net instead of

Response.End

Use

HttpContext.Current.ApplicationInstance.CompleteRequest()

Code Snippets, Tip of the Day

Tip of the Day

15. June 2009

Sometimes your asp.net pages work better when you don't accidently delete the whole Page_Load method.

Tip of the Day