Ch07
Ch07
subscript
mtbNumber
txtWinner
California
1850
Sacramento
Eureka
• LINQ Queries
• The Distinct Operator
• The ToArray Method
• Use of Function Procedures in Queries
• The Let Operator
• The OrderBy Operator
• The DataSource Property
• Binary Search
© 2017 Pearson Education, Inc.
Hoboken, NJ. All rights reserved. 42
What is LINQ?
Output: 12
8
11
© 2017 Pearson Education, Inc.
Hoboken, NJ. All rights reserved. 48
Variation on Example 2
Output: 8
12
31
Output: 144
64
121
© 2017 Pearson Education, Inc.
Hoboken, NJ. All rights reserved. 50
Distinct Operator
Dim nums() As Integer = {5, 12, 5, 7, 12}
Dim numQuery = From num In nums
Select num
Distinct
For Each num As Integer In numQuery
lstBox.Items.Add(num)
Next
Output: 5
12
7
© 2017 Pearson Education, Inc.
Hoboken, NJ. All rights reserved. 51
ToArray Method
Output: 1
3
4
6
• Structures
• Arrays of Structures
• The DataGridView Control
• Searching an Array of Structures
• Using General Procedures with Structures
• Displaying and Comparing Structure Values
• Complex Structures (Optional)
© 2017 Pearson Education, Inc.
Hoboken, NJ. All rights reserved. 62
Structures
A structure is a grouping of heterogeneous data.
Also called a UDT (User Defined Type)
Sample structure definition:
Structure Nation
Dim name As String
Dim continent As String
Dim population As Double 'in millions
Dim area As Double 'in square miles
End Structure
Structure College
Dim name As String
Dim state As String 'state abbreviation
Dim yearFounded As Integer
End Structure
Sample records
Harvard U.,MA,1636
William and Mary,VA,1693
Yale U.,CT,1701
U. of Pennsylvania,PA,1740
DataGridView
control
column
row headers
headers
Structure Grades
Dim exam1 As Double
Dim exam2 As Double
Dim final As Double
End Structure
Member Types
• Integer, Decimal, Double, String, etc.
• Another User Defined Type
• Array
• Must not specify range
• Range must be set using ReDim
Chicago LA NY Philly
Chicago 0 2054 802 738
LA 2054 0 2786 2706