Clarification of some serialization (design) issues

G

Guest

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.
 
C

Cor Ligthert

Crispin,
I was after clarification of some of serialization issues. I think I know
the answers, but I want to be sure.

This is a newsgroup done by individuals, not by Microsoft. All messages are
given "as is" you never will be sure when somebody gives you an answer, it
is too help you to find a solution or to discuss to find together good
solutions.

In my opinion can only testing by yourself make your "sure".

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top