Xem mẫu
CHAPTER TEN
Working with Arrays and Collections
10- 2 Introduction
• An array is a variable with a single symbolic name that represents many different data items.
• Visual Basic .NET provides a number of classes that manage collections of objects.
• A collection of objects is like an array in that one collection is associated with many objects.
• This chapter covers the ArrayList, Hashtable, and SortedList collections.
McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved.
10- 3 Objectives
• Explain why arrays are needed to solve many types of problems.
• Construct an array to store multiple related data values.
• Use ArrayList, Hashtable, and SortedList collections to store and process data values.
McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved.
10- 4 10.1 Solving Problems with Arrays
• Simple variable means a variable that can store only one value.
• The Problem
– Calculate the rate of return for 10 different companies and those companies who exceeded the average of the group.
McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved.
10- 5 10.1 Solving Problems with Arrays (cont.)
• The Solution Using Simple Variables
– Write the pseudocode for the problem solution. • Two passes through the data:
– One to compute the average.
– Two to determine who exceeds the average. – Not a good way to solve the problem.
McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved.
...
- tailieumienphi.vn
nguon tai.lieu . vn