From: Ed on
Hello,

How do I write/read a List(Of SqlDouble) (or its underlying array of
SqlDouble) with BinaryReader and BinaryWriter?

I am writing a SQL Server CLR function and am using a List(Of SqlDouble) to
hold the values for processing. The class must implement IBinarySerialize
which as two methods. Read passes a BinaryReader and Write passes a
BinaryWriter. I've seen SQL Server CLR function examples that serialise
with XmlTextReader and XmlTextWriter but I'd like to use the binary ones
being passed in since it will be faster and I think writing numbers as text
is not ideal when it is an intermediate step in a calculation.

When writing I'll know how many entires there are but when reading I wont
know how many are in the BinaryReader. I thought that I could write an
Integer with the number of items in the List and then write each item as a
SqlDouble. Using the same method to read back. But I was hoping that there
was some way to write the List (or its underlying array to the read/write in
one statement instead of looping through.

Your assistance will be greatly appreciated.

Thanks,

Ed