Posts tagged Decimal to Byte array (vice versa)
Decimal to Byte array (vice versa)
Feb 26th
1: public static byte[] DecimalToBytes(Decimal dec) 2: { 3: using (MemoryStream stream = new MemoryStream()) 4: { 5: using (BinaryWriter writer = new BinaryWriter(stream)) 6: { 7: writer.Write(dec); 8: return stream.ToArray(); 9: } 10: } 11: } 1: public static Decimal BytesToDecimal(byte[] src) 2: { 3: if (src.Length == 1) 4: { 5: return Decimal.Parse(((char)src[0]).ToString()); [...]