This topic provides code samples for LINQ and Lambda expressions.
-
Gets the first list item that matches "Meyer"
myString = myList.Find(Function(x) x.Equals("Meyer"))
-
Gets the first list item that contains "Meyer" or "Mayer"
myString = myList.Find(Function(x) x.Contains("Meyer") OR x.Contains("Mayer"))
-
Gets a sorted list ordered by the first column in ascending order, then by the second column.
mySortedList = myUnsortedList.OrderBy(Function(x) x(0).ThenBy(Function(x) x(1)).ToList()
-
Gets a sorted dictionary, ordered from highest to lowest value.
mySortedDictionary = myDictionary.OrderByDescending(Function(x) x.value).ToDictionary(Function(x) x.Key, Function(x) x.Value)