Properties
Regarding the Hashtable class, ht.Items.Add(x)
Public ReadOnly Property Items As ListItemCollection
What is the relationship between the above property and the public class ListItemCollection.
The below code is a simple class using a property to access another.
ca.Items.Add - Does this create a new instance of ClassB wihtin ClassA, I'm not sure
because with the HashTable class "Items" is a property and "Add" is a method of the type that Items refers to. The relation to HashTable is I have a dropdownlist control called c1. Now the statement c1.Items.Add(listItem) called X times. Wouldn't an instance of ListItemCollection be associated with dropdownlist c1.
Thanks.
<script runat="server">
Public Class ClassB
private count As Integer = 0
Sub Add()
count = count + 1
End Sub
Function getCount
return count
End Function
End Class
Public class ClassA
Public ReadOnly Property Counter As ClassB
Get
return new ClassB
End Get
End Property
End Class
Sub Page_Load
Dim ca As New ClassA
ca.Counter.Add
Response.Write(ca.Counter.getCount)
End Sub
</script>
|