Casting IQueryable List

Occasionally I run into situations where I have a List of objects that I need to cast to a list of specific types. One option would be to iterate through the list of objects and cast each item individually and add them to a new list of the specific type. 

  1. Dim countries As New List(Of Country)
  2. For Each item As Object In items
  3.     countries.Add(DirectCast(item, Country))
  4. Next

Another more cleaner option would be to use a Linq statement.

  1. Dim countries As New List(Of Country)
  2. countries = items.Cast(Of Country).ToList()