c#将字节数组转换成数字
代码:
复制代码 代码示例:
// Create a decimal from a byte array
public static decimal ByteArrayToDecimal (byte[] src) {
// Create a MemoryStream containing the byte array
using (MemoryStream stream = new MemoryStream(src)) {
// Create a BinaryReader to read the decimal from the stream
using (BinaryReader reader = new BinaryReader(stream)) {
// Read and return the decimal from the
// BinaryReader/MemoryStream
return reader.ReadDecimal();
}
}
}