Discussion:
LINQ Help
(too old to reply)
Dennis Macdonald
2012-02-06 04:54:37 UTC
Permalink
Hi, I;m new to LINQ and need some help crwating a query.

I have 2 structures, 1 structure as follows;

Private Structure AA
Dim aName As String
Dim aCompany As String
Dim aSize as integer
End Structure

and I have another structure as follows;

Private Structure BB
Dim MyIndex As String
Dim bAddress As String
Dim aZip as integer
End Structure

I have 2 arrays Array0 of AA and Array1 of BB and what I need is the
interection of the array0 and array1 where aName in Array0 = MyIndex
in Array1.

Appreciate any help with this.

Cheers,
Dennis.
Peter Duniho
2012-02-07 08:37:57 UTC
Permalink
Post by Dennis Macdonald
Hi, I;m new to LINQ and need some help crwating a query.
I have 2 structures, 1 structure as follows;
Private Structure AA
Dim aName As String
Dim aCompany As String
Dim aSize as integer
End Structure
and I have another structure as follows;
Private Structure BB
Dim MyIndex As String
Dim bAddress As String
Dim aZip as integer
End Structure
I have 2 arrays Array0 of AA and Array1 of BB and what I need is the
interection of the array0 and array1 where aName in Array0 = MyIndex
in Array1.
I believe the word you are looking for is "join", not "intersection". You
can't take the intersection of two disparate sets (i.e. where the two sets
contain completely different types of objects).

A "join" will create a whole new type, representing the desired combination
of the first two. The functionality is implemented by the
System.Linq.Enumerable.Join() method. In C#, you use the "join" keyword in
a LINQ expression:
http://msdn.microsoft.com/en-us/library/bb397941.aspx

This page describes the VB.NET version of the same thing:
http://msdn.microsoft.com/en-us/library/bb918093.aspx

Pete

Loading...