I have开发者_JAVA技巧 an OLEVariant disguised as a .Net object that I recieve from a client-side component over the net. I know that the contents are an array of bytes, but I don't know how to convert those contents to a native .Net byte array (byte[]). Any clues on how I can accomplish the conversion?
Edit: We answered our own question. To take an OleVariant (of type array of bytes) to a .Net byte[] requires pumping the object as it comes in into a .Net Array, taking the Array's upper bounds, creating a new byte[] of upperbound size and then finally doing an Array.Copy().
Cast the object to byte[] with (byte[])myobj
or myobj as byte[]
.
精彩评论