本文實例講述了C#將字節數組轉換成數字的方法。分享給大家供大家參考。具體實現方法如下:
// Create a decimal from a byte arraypublic 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#程序設計有所幫助。
新聞熱點
疑難解答