Download presentation
Presentation is loading. Please wait.
1
Collections, Part 2 You were introduced to Generic collections for assignment 3—ThingsToDraw was a Generic.List of Idrawable objects. Since the Generic.List is a collection of objects, it follows the object-oriented method of data storage: Like an object variable, the Generic.List contains the memory addresses of the objects, not the objects themselves. 1
2
Object Variables Recall this sample program from earlier, showing approximately how object data is stored and accessed by variables in VB: 2
3
Object Collections and Assignments This form demonstrated how object arrays work: Generic Collections work in a very similar fashion: Like the yellow box above, they are collections of addresses—not the actual objects. This means that if you have another reference (a variable name, or as a member of another collection) to one of its objects, if you modify the object using one reference, it modifies the object for all references. 3
4
Example Above is some simple code which: – Creates a Generic.List(Of Student) – Creates a new Student object and assigns it to the variable s (which will then contain the address of the Student object) – Adds the object to the Generic.List (which also now contains the address of the object) – Modifies the object using the variable – This causes the object stored in the Generic.List to be modified as well, because it is the same object (not a copy) 4
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.