Convert object type to byte[]

  • Thread starter Thread starter Kimelia Schiles
  • Start date Start date
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
 
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
 
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

Similar Threads

Convert to Byte 5
AND operator with byte operands 2
Byte[] Conversion 15
convert string to byte array 13
how to convert byte[] to object[] 5
convert hex string to byte[] 5
Boolean values to bytes 1
copy byte array 2

Back
Top