LINQ and Lambda Expressions

  • myString = myList.Find(Function(x) x.Equals("Meyer")) [returns first list item that matches "Meyer"]
  • myString = myList.Find(Function(x) x.Contains("Meyer") OR x.Contains("Mayer")) [returns first list item that contains "Meyer" or "Mayer"]
  • mySortedList = myUnsortedList.OrderBy(Function(x) x(0).ThenBy(Function(x) x(1)).ToList() [returns a sorted list ordered ascendingly by the first and then by the second column]
  • mySortedDictionary = myDictionary.OrderByDescending(Function(x) x.value).ToDictionary(Function(x) x.Key, Function(x) x.Value) [returns a sorted dictionary ordered by the highest to the lowest value]
Was this article helpful?
0 out of 0 found this helpful