home *** CD-ROM | disk | FTP | other *** search
- ' two classes that extend BinaryWriter and BinaryReader to support the Person object
-
- Class BinaryWriterEx
- Inherits System.IO.BinaryWriter
-
- Sub New(ByVal st As System.IO.Stream)
- MyBase.New(st)
- End Sub
-
- ' Add to the series of Write methods.
- Overloads Sub Write(ByVal p As Person)
- MyBase.Write(p.FirstName)
- MyBase.Write(p.LastName)
- End Sub
- End Class
-
- Class BinaryReaderEx
- Inherits System.IO.BinaryReader
-
- Sub New(ByVal st As System.IO.Stream)
- MyBase.New(st)
- End Sub
-
- ' A custom function that reads Person objects.
- Function ReadPerson() As Person
- Dim FirstName As String = MyBase.ReadString()
- Dim LastName As String = MyBase.ReadString()
- ReadPerson = New Person(FirstName, LastName)
- End Function
- End Class
-
- ' the Person sample classes used by BinaryWriterEx and BinaryReaderEx
-
- Class Person
- Public FirstName As String
- Public LastName As String
-
- Sub New(ByVal firstName As String, ByVal lastName As String)
- Me.FirstName = firstName
- Me.LastName = lastName
- End Sub
- End Class
-
-
-