Serializing an Array

A

Andrew

Can anyone tell me if there is an equivalent VB.Net function to php serialize?
I need to then encode the serialized string (or array of strings) and then
use a function similar to php base64_encode to encode the results from the
serialization?
 
T

Tom Shelton

Can anyone tell me if there is an equivalent VB.Net function to php serialize?
I need to then encode the serialized string (or array of strings) and then
use a function similar to php base64_encode to encode the results from the
serialization?

As long as the contents of the array are serializable... Then sure, you can
do something like:

Imports System
Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary

....

Dim bin As New BinaryFormatter
Dim mem As New MemoryStream

bin.Serialize(mem, yourArray)

Dim b64 As String = System.Convert.ToBase64String(mem.GetBuffer())

Anyway - that's air code, but should be enough to get you started :)
 
A

Andrew

Awesome, thanks Tom, that's pretty much what I had except for I had one error
giving me grief;

System.Convert.ToBase64String(mem)

I was starting to think I was going to wrong way and started looking at
trying to read the MemoryStream into a string, but decided to post the
question, i'm very glad I did! Again, much appreciate your help.

Andrew
 

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