Parameterized Properties
You know you can have array fields in structures and classes. You also can have attribute of type array, or more generally parameterized attributes. How can you implement these attributes using properties? Let's look at an example. Assume that your Person class can have a number of accounts with a financial institution. You plan to store the balances of these accounts in the Person class. You can further assume (for simplification) that the maximum number of accounts is five. You decide to implement this attribute using an array field of five Decimal values. If you were to use the public array field, you could write the class as follows:
Public Class Person
Private m_name As String
Private m_dob As Date
Public m_balances() ...
Get Visual Basic® .NET by Example 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.