Ah, that explains it. Take a look at this:
Code:
Public Shared Quantities(500, 4) AsInteger' 0:index
A Shared variable exists on the class where you define it. At any tme, there's only one instance of that property throughout the entire application domain. In other words: all users have access to the same variable. If user A adds an item and user B queries the Quantities property, she'll see stuff added by user A. This is a bad design choice, as you won't be able to differentiate among users anymore. Now, take another look at my ShoopingCart property:
Code:
Public Shared ReadOnly Property ShoppingCart() As ShoppingCart
Get
If HttpContext.Current.Session("ShoppingCart") Is Nothing Then
HttpContext.Current.Session("ShoppingCart") = New ShoppingCart()
End If
Return CType(HttpContext.Current.Session("ShoppingCart"), ShoppingCart)
End Get
End Property
Althrough the property itself is marked as shared, its backing store is user scoped. This gives each user a unique shopping cart which isn't shared by others.
Hope this helps,
Imar