Converting a memory stream into an array of floats

Posted on 2005-04-13
Medium Priority
Last Modified: 2006-11-18
I have a memory stream coming from a BinaryMessageFormatter; I know the contents are floating point numbers.  How do I make the conversion into an array of floats? Please provide an example.  Thanks!
Question by:jumanac
1 Comment

Accepted Solution

wishguitar earned 1000 total points
ID: 13775625
BinaryMessageFormatter formatter = new BinaryMessageFormatter();
Message message = new Message();
float [] messageBody = new float [] { 1.2f, 2.3f, 3.4f };


message.BodyStream.Position = 0;
float [] newMessageBody = (float [])formatter.Read(message);

foreach (float f in newMessageBody)

Console.WriteLine("Press <Enter> to exit...");

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question