Book contents
- Frontmatter
- Contents
- Preface
- Chapter 1 An Overview of the Visual Basic.NET Language
- Chapter 2 An Overview of Object-Oriented Programming
- Chapter 3 Structures
- Chapter 4 Classes
- Chapter 5 Access Modifiers
- Chapter 6 Abstract Classes and Interfaces
- Chapter 7 Implementing the IEnumerable and IComparable Interfaces
- Chapter 8 Designing and Implementing Exception Classes
- Chapter 9 Design Patterns and Refactoring
- Chapter 10 Object Internals: Reflection and Attributes
- Chapter 11 Object Persistence: Serialization
- Chapter 12 Building a Windows Application
- Chapter 13 Database Programming Using ADO.NET
- References
- Index
Chapter 3 - Structures
Published online by Cambridge University Press: 06 July 2010
- Frontmatter
- Contents
- Preface
- Chapter 1 An Overview of the Visual Basic.NET Language
- Chapter 2 An Overview of Object-Oriented Programming
- Chapter 3 Structures
- Chapter 4 Classes
- Chapter 5 Access Modifiers
- Chapter 6 Abstract Classes and Interfaces
- Chapter 7 Implementing the IEnumerable and IComparable Interfaces
- Chapter 8 Designing and Implementing Exception Classes
- Chapter 9 Design Patterns and Refactoring
- Chapter 10 Object Internals: Reflection and Attributes
- Chapter 11 Object Persistence: Serialization
- Chapter 12 Building a Windows Application
- Chapter 13 Database Programming Using ADO.NET
- References
- Index
Summary
A structure is a user-defined data type that allows a single variable to store more than one type of data. In Visual Basic 6, structures were actually called user-defined types. The structure object has been improved in VB.NET, however, because VB.NET structures can contain both data and subprocedures to operate on those data. Structures are very common in form to classes, though they have several limitations that restrict their use to solve object-oriented programming problems. Because they are similar in form to classes, structures provide an excellent introduction to the use of classes, which is why we spend an entire chapter discussing them.
USING STRUCTURES
In Chapter 2 you were introduced to the concept of the abstract data type. To implement an ADT in VB.NET, we need to use a special data type called a structure. A structure allows us to store multiple components of different data types in one logical unit. In some languages structures are known as records.
The atomic data types (Integer, Single, String) allow us to store only single data items in a variable, as does an array (well, not strictly, since an array can be of type Object). For example, when we store a number in an Integer variable, we can only store one number in the variable. With structures, we can store more than one piece of the data in the structure and the data can be of different types.
- Type
- Chapter
- Information
- Object-Oriented Programming with Visual Basic.NET , pp. 64 - 92Publisher: Cambridge University PressPrint publication year: 2004