using System.IO; // Create a new FileStream object to read data from a file FileStream fileStream = new FileStream("data.txt", FileMode.Open); // Create a new BinaryReader object to read binary data from the file stream BinaryReader binaryReader = new BinaryReader(fileStream); // Read a Double value from the file using the BinaryReader Double doubleValue = binaryReader.ReadDouble(); // Close the BinaryReader and FileStream objects binaryReader.Close(); fileStream.Close();
using System.IO; // Create a new MemoryStream object to read data from a byte array byte[] byteArray = new byte[] { 0x40, 0x49, 0x0f, 0xdb, 0x5e, 0xba, 0x74, 0x8b }; MemoryStream memoryStream = new MemoryStream(byteArray); // Create a new BinaryReader object to read binary data from the memory stream BinaryReader binaryReader = new BinaryReader(memoryStream); // Read a Double value from the memory stream using the BinaryReader Double doubleValue = binaryReader.ReadDouble(); // Close the BinaryReader and MemoryStream objects binaryReader.Close(); memoryStream.Close();Package/Library: The BinaryReader and MemoryStream classes are part of the System.IO namespace in the .NET Framework class library. Therefore, the package/library in use is the .NET Framework class library.