开发者

OLEVariant to .Net byte[]

开发者 https://www.devze.com 2022-12-11 23:16 出处:网络
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 conver

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[] .

0

精彩评论

暂无评论...
验证码 换一张
取 消