I was after clarification of some of serialization issues. I think I know
the answers, but I want to be sure.
1. In a serializable collection class is it mandatory (for serialization) to
have a default Item property that is effectively
indexed by the IList index?
Example 1
---------
Default Public ReadOnly Property Item(Index As Integer) As MyObject
Get
Return DirectCast(List.Item(Index), MyObject)
End Get
End Property
2. Is there ever an occasion when this property is not read-only? If so, do
you have an example?
3. It's possible for the Item property to have an alternative version with
another signature:
Example 2
---------
Default Public ReadOnly Property Item(KeyValue As String) As MyObject
Get
Dim objChild as MyObject
For Each objChild in List
If objChild.KeyValue.Equals(KeyValue) Then
Return DirectCast(List.Item(Index), MyObject)
End If
Next
Return Nothing
End Get
End Property
but an integer key value (ie KeyValue As Integer in the above) would have
the same signature as Example 1 which rules it out (unless
someone knows better).
So if it's mandatory to have an Item property indexed by the List index,
what's the best practice for returning an object which is
referenced by the key value - which will be more than likely a Primary Key
integer value from SQL Server?
TIA
Crispin
PS The web based newgroup system was having a few problems. Apologies if
this post turns up more than once.