Mega Code Archive

 
Categories / VB.Net / Data Structure
 

Enumerable Except produces the set difference of two sequences by using the default equality comparer to compare values

Imports System Imports System.Linq Imports System.Collections.Generic Public Class Example     Public Shared Sub Main()                   ' Create two arrays of doubles.         Dim numbers1() As Double = {2.0, 2.1, 2.2, 2.3, 2.4, 2.5}         Dim numbers2() As Double = {2.2}         ' Select the elements from the first array that are not         ' in the second array.         Dim onlyInFirstSet As IEnumerable(Of Double) = numbers1.Except(numbers2)         For Each number As Double In onlyInFirstSet             Console.WriteLine(number)         Next     End Sub End Class