Converting object to string.

  • Thread starter Thread starter bryja_klaudiusz[at]poczta[dot]fm
  • Start date Start date
B

bryja_klaudiusz[at]poczta[dot]fm

Hi,

How to convert object to string? I try procedure like this (when I have
byte array I convert it to string):

public byte[] ObjectToByteArray(Object obj)
{
MemoryStream fs = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();

try
{
formatter.Serialize(fs, obj);
return fs.ToArray() ;
}
catch(SerializationException e)
{
return null;
}
finally
{
fs.Close();
}
}

and it's not working properly.

For example - I have to finally get string "UG " but I get
"\0\0\0\0????\0\0\0\0\0\0\0\0\0\0\f\0\0\0554720202020\v" from
object with byte array 53, 53, 52, 55, 50, 48, 50, 48, 50, 48, 50, 48.

This object is generated from dbf file and I'm using Microsoft Visual
Fox Pro driver and odbc dataset and dataadapter. The worst think is that
in dataset I have to fields which are characters fields as example above
and for this field everything working ok.
 

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

Back
Top