Shared Members Definition

To better understand shared members, we will start with an example. Let's assume that you have to code a class that models a product sold in a shop and that the shop is geographically situated in a state or country that has a sales tax. Your product class will have to calculate the price charged for the product, based on the list price of the product, the sales tax, any discounts entered by the sales clerk, and the quantity purchased. You could design and then implement a class like the one shown here:

Public Class Product
   Private m_name As String ' product name
   Private m_listPrice As Decimal ' the list price
   Private m_taxRate As Double Public ReadOnly Property name() As String Get Return m_name End Get End Property ...

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.