what about the old way?
public static decimal[] Bytes2Decimal(byte[] bytes)
{
decimal[] toReturn = new decimal[bytes.Length];
for(int i = 0; i < bytes.Length; i++)
toReturn[i] = Convert.ToDecimal(bytes[i]);
return toReturn;
}
2009/11/25 Cerebrus <[email protected]>
> What's wrong with BinaryFormatter.Deserialize() ?
>
> On Nov 24, 9:16 pm, wigzell <[email protected]> wrote:
> > In C#, I create a byte[] using BinaryFormatter etc. as follows:
> >
> > decimal[] theArray = new decimal[2];
> > theArray[0] = (decimal) 36300288.734436237;
> > theArray[1] = (decimal) 34176522.502899267;
> > BinaryFormatter bf = new BinaryFormatter();
> > MemoryStream ms = new MemoryStream();
> > bf.Serialize(ms, theArray);
> > byte[] bytes = ms.GetBuffer();
> >
> > This is then stored to SQL Server 2005 in varbinary field. When
> > loading this from SQL, I get the byte[] back - so my question is, how
> > do I convert the byte[] back to the decimal[]?
> >
> > Many thanks,
> > Cathy
>