Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am serializing objects to send XML over a socket. Creating a class like this and serialize it works fine for me:

 

<MESSAGE>

<FROM>Me</FROM>

<TO>You</TO>

<MESSAGE>

 

And the class look something like this:

 

Public Class MESSAGE

Private _to As String

Private _from As String

Public Property to() As String

Get

Return _to

End Get

Set(ByVal to As String)

_to = to

End Set

End Property

Public Property from() As String

Get

Return _from

End Get

Set(ByVal from As String)

_from = from

End Set

End Property

End Class

 

But because I'm new to OOP I need help creating a class like this.

 

<CHATTERS>

<CHATTER>

<NAME>Name 1</NAME>

</CHATTER>

<CHATTER>

<NAME>Name 2</NAME>

</CHATTER>

</CHATTER>

 

That is, I want to have a collection of CHATTER in CHATTERS. I guess I have to add them with some kind of function. Does anybody have an example of how to solve this?

  • *Experts*
Posted

Chatters needs to be a collection of some sort.

Dim chatters As New ArrayList()
Dim c1 As New Chatter()
Dim c2 As New Chatter()

c1.Name = "blah"
c2.Name = "whatever"

chatters.Add(c1)
chatters.Add(c2)

' Then you can serialize the chatters class

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...