C#將字節數組轉換成數字的辦法。本站提示廣大學習愛好者:(C#將字節數組轉換成數字的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#將字節數組轉換成數字的辦法正文
本文實例講述了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();
}
}
}
願望本文所述對年夜家的C#法式設計有所贊助。