C#: read the number from buffer

1. read from stream:

  byte[] arrData = {0, 0, 0, 0, 0, 0, 0xF0, 0xBF}; 
  Double dbl; 
  MemoryStream ms = new MemoryStream(); 
  ms.Write(arrData, 0, 8); 
  ms.Position = 0; 
  BinaryReader br = new BinaryReader(ms); 
  dbl = br.ReadDouble();

2. copy/convert from buffer:

  dbl = BitConverter.ToDouble(arrData, 0);

Tags:

Comments are closed.