10/15/2009 9:18:27 PM
LINQ is a very powerful tool in the .NET framework. Below is a sample that shows how to use LINQ to randomize a list of objects.
Let's assume we have a list of objects names myList, using LINQ we can return the list in a random order:
Protected Function RandomizeList(myList as List(Of x)) as List(Of x)
Dim r as New Random(Now.Millisecond)
Return (From myX as x In myList Order By r.Next() Select myX).ToList()
End Function
LINQ makes it very easy for use to perform actions that would normally require complex code or another trip to the database. Thank you LINQ for saving me some effort.
Tags:.NET LINQ 2e855e2a-79d5-4582-bd21-7285a8e43dd0