O'Reilly logo

Visual Basic® .NET by Example by Bob Donald, Gabriel Oancea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required