Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This example shows how to use LINQ to compare two lists of strings and output those lines that are in names1.txt but not in names2.txt.
Class CompareLists
Shared Sub Main()
' Create the IEnumerable data sources.
Dim names1 As String() = System.IO.File.ReadAllLines("../../../names1.txt")
Dim names2 As String() = System.IO.File.ReadAllLines("../../../names2.txt")
' Create the query. Note that method syntax must be used here.
Dim differenceQuery = names1.Except(names2)
Console.WriteLine("The following lines are in names1.txt but not names2.txt")
' Execute the query.
For Each name As String In differenceQuery
Console.WriteLine(name)
Next
' Keep console window open in debug mode.
Console.WriteLine("Press any key to exit.")
Console.ReadKey()
End Sub
End Class
' Output:
' The following lines are in names1.txt but not names2.txt
' Potra, Cristina
' Noriega, Fabricio
' Aw, Kam Foo
' Toyoshima, Tim
' Guy, Wey Yuan
' Garcia, Debra
Some types of query operations in Visual Basic, such as Except, Distinct, Union, and Concat, can only be expressed in method-based syntax.
Create a Visual Basic console application project, with an Imports
statement for the System.Linq namespace.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Store and apply operations on list data in F# - Training
This module covers collections in F#, with a specific focus on lists.