Converting a memory stream into an array of floats

Posted on 2005-04-13
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
    LVL 3

    Accepted Solution

    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...");

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video discusses moving either the default database or any database to a new volume.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now