G
Guest
Hi All,
I am trying to convert an ArrayList (that can contain an array of any type)
to a byte array.
Using the BinaryWriter and BinaryReader is not helpful, for example since
the ArrayList can contain an array of doubles it is necessary to cast the
following:
binWriter.Write((double)dblArrayList[0]);
However since the ArrayList can be of any type it is not possible (or is it)
to perform a cast at run time.
So what is desired is to have a mechanism that will perform conversions of
an ArrayList (of any type) to a byte array and to do the reverse, convert a
byte array back to an array list.
Note that the type is known by saving the type in a struct as a string I.E.:
"System.Double" along with the ArrayList.
Thanks for any help in advance.
Scott
I am trying to convert an ArrayList (that can contain an array of any type)
to a byte array.
Using the BinaryWriter and BinaryReader is not helpful, for example since
the ArrayList can contain an array of doubles it is necessary to cast the
following:
binWriter.Write((double)dblArrayList[0]);
However since the ArrayList can be of any type it is not possible (or is it)
to perform a cast at run time.
So what is desired is to have a mechanism that will perform conversions of
an ArrayList (of any type) to a byte array and to do the reverse, convert a
byte array back to an array list.
Note that the type is known by saving the type in a struct as a string I.E.:
"System.Double" along with the ArrayList.
Thanks for any help in advance.
Scott