Working with binary data

Posted on 2006-04-27
Last Modified: 2010-04-16
I'm doing some hard core C#\.NET socket program and have a pressing question about dealing with binary data.  I've done similar work in Java, and have found the ByteBuffer class in Java's NIO package invaluable.  I was wondering if there is a similar class (either part of the .NET SDK or 3rd party) for managing binary data in C#.  The specific operations I would need support for are append, find, cut, and copy, and would want the class to keep track of its current position etc...

If it turns out all I can work with are native .NET arrays, are there any methods for bulk cutting\copying and appending on them?
Question by:derekl
    LVL 52

    Accepted Solution

    The System.Collections namespace contains a BitArray object which may suit your needs.
    LVL 19

    Assisted Solution

    by:Daniel Van Der Werken
    LVL 37

    Assisted Solution

    as for moving data around ... its not as simple as always using blockcopy ..

    Given the operations that you mention ... MemoryStream would probably be a good starting point for you.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 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

    15 Experts available now in Live!

    Get 1:1 Help Now