Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections

Similar presentations


Presentation on theme: "CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections"— Presentation transcript:

1 CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections
UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous lecture slides. – Xiang Lian

2 Objectives In this chapter, you will do some exercises related to:
Arrays LINQ

3 Exercises The number that refers to a particular element of an array is called its ________. 1. value 2. size 3. indexed array name 4. index (or subscript) The indexed array name of one-dimensional array units's element 2 is _______. 1. units{2} 2. units(2) 3. units[0, 2] 4. units [2] An array’s length is ______. 1. one more than the array’s last index 2. one less than the array’s last index 3. the same as the array’s last index 4. returned by method GetUpperBound The process of ordering the elements of an array is called ____ the array. 1. allocating 2. sorting 3. declaring 4. initializing

4 Exercises (cont'd) Which of the following sorts array averageRainfall?
1. Array(averageRainfall).Sort() 2. Sort.Array(averageRainfall 3. Sort(averageRainfall) 4. Array.Sort(averageRainfall) Array that use two indices are referred to as _____array. 1. single-subscripted 2. two-dimensional 3. double 4. one-dimensional The expression _____creates an Integer array of two rows and five columns. 1. Dim a(2, 5) As Integer 2. Dim a(1, 5) As Integer 3. Dim a(1, 4) As Integer Dim a(2, 4) As Integer Typically, ______statements are used to iterate over each element in a two-dimensional array. 1. Do While … Loop 2. nested For … Next 3. Do … Loop Until 4. nested Do … Loop While

5 Exercises (cont'd) Property______specifies the source of the data displayed in ComboBox. 1. ComboData 2. Source 3. DataList 4. DataSource ComboBox property _______is 0 when the first ComboBox is selected. 1. SelectedIndex 2. SelectedValue 3. Index 4. SelectedNumber The ____property determines whether a RadioButton is selected. 1. Selected Clicked Checked Enabled The _____event is raised when a RadioButton is either selected or deselected. 1. CheckedChanged 2. Changed 3. SelectedChanged 4. None of the above When one RadioButton in a container is selected, _____. 1. others can be selected at the same time 2. a logic error will occur 3. all others will be deselected 4. both 1 and 2.

6 Exercises (cont'd) The LINQ ______clause is used for filtering
1. Order By 2. From … In 3. Where 4. Select To sort the elements of an LINQ query, use ___ clause. Which extension method can determine the number of elements in the result of an LINQ query? 1. Sum 2. Distinct 3. Length Count

7 True / False Statements
An array can store many different types of values An array index normally should be of type Double Method GetUpperBound returns the highest numbered index in an array To determine the number of elements in an array, use the NumberOfElements property The linear search works well for unsorted arrays

8 True / False Statements (cont'd)
The Select clause in an LINQ query is optional The Order By clause of an LINQ query by default sorts the array in descending order LINQ can query arrays of only primitive types

9 What is Wrong With This Code?
This code is supposed to create a 2D array and initialize all its values to one Sub TwoDArray() Dim array(3, 3) As Integer For i As Integer = 0 To 3 array(i, i) = 1 Next End Sub

10 Write a Program Write a complete program to generate random number between 1 and 99, and output the resulting number to a resultTextBox.

11 Write a Program (cont'd)
Declare an array, numArray, to hold 100 integer numbers Assign random numbers within [1, 100] into this array Sort this array Check whether a number 50 exists in this array using the linear search and For Each…Next statement Output the multiplication of all even integers in this array; if no even numbers exist, then output 0

12


Download ppt "CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections"

Similar presentations


Ads by Google