Convert object type to byte[]

K

Kimelia Schiles

Hi,

I would like to know how to convert the value with return type of object to
a byte array. For example:

byte[] photo = ds.Tables[0].Rows["Photo"];

Thanks and have a nice day
 
D

David Hogue

If the contents of ds.Tables[0].Rows["Photo"] is an array of bytes, then
all you need to do is cast to byte[]:

byte[] photo = (byte[])ds.Tables[0].Rows["Photo"];

If you're actually trying to convert an object to an array of bytes,
that involves a bit more work and depends on what type you are
converting from (Image or Stream or whatever)


Kimelia said:
Hi,

I would like to know how to convert the value with return type of object to
a byte array. For example:

byte[] photo = ds.Tables[0].Rows["Photo"];

Thanks and have a nice day
 
?

=?ISO-8859-1?Q?Sebastian_Kr=E4mer?=

Kimelia said:
Hi,

I would like to know how to convert the value with return type of object to
a byte array. For example:

byte[] photo = ds.Tables[0].Rows["Photo"];

I've seen many useful methods for writing to/from byte[] in the
InteropServices namespace. But somehow I think it won't help you with
ds.. Anyway, have a look ;)

Sebastian
 

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