Chapter 26. Classes and Structures

A variable holds a single value. It may be a simple value such as an Integer or String, or a reference that points to a more complex entity. Two kinds of more complex entities are classes and structures.

Classes and structures are both container types. They group several related data values into a convenient package that you can manipulate as a group.

For example, an EmployeeInfo structure might contain fields that hold information about an employee (such as first name, last name, employee ID, office number, extension, and so on). If you make an EmployeeInfo structure and fill it with the data for a particular employee, you can then move the structure around as a single unit instead of passing around a bunch of separate variables holding the first name, last name, and the rest.

This chapter explains how to declare classes and structures, and how to create instances of them (instantiate them). It explains the differences between classes and structures and provides some advice about which to use under different circumstances.

Finally, this chapter describes some of the mechanical issues that you'll face when building classes. It explains how garbage collection affects objects. It finishes by explaining how to implement some of the most basic features of classes: constants, properties, methods, and events.

CLASSES

A class packages data and related behavior. For example, a WorkOrder class might store data describing a customer's work order in its properties. ...

Get Visual Basic® 2010 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.