Using Default Properties

Visual Basic 6 supported a wide variety of properties as default properties. This worked because we were required to use Let, Get, and Set when performing read and write operations against an object in VB6. However, Let, Get, and Set are not required or supported for VB .NET, so the compiler no longer has that codified cue. As a result a new cue was needed to differentiate a default property from an object assignment. The decision was made to support default properties only for properties that defined an indexer. The indexer is not require to be an integer, but the property must have an argument for us to use the Default keyword.

An example of a class with a default property is a class that has an Item property. Item ...

Get Visual Basic® .NET Power Coding 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.