Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3284384
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:08:55+00:00 2026-05-17T20:08:55+00:00

This is a simple one, and one that I thought would have been answered.

  • 0

This is a simple one, and one that I thought would have been answered. I did try to find an answer on here, but didn’t come up with anything – so apologies if there is something I have missed.

Anyway, is there an equivalent of StringBuilder but for byte arrays?

I’m not bothered about all the different overloads of Append() – but I’d like to see Append(byte) and Append(byte[]).

Is there anything around or is it roll-your-own time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:08:55+00:00Added an answer on May 17, 2026 at 8:08 pm

    Would MemoryStream work for you? The interface might not be quite as convenient, but it offers a simple way to append bytes, and when you are done you can get the contents as a byte[] by calling ToArray().

    A more StringBuilder-like interface could probably be achieved by making an extension method.

    Update
    Extension methods could look like this:

    public static class MemoryStreamExtensions
    {
        public static void Append(this MemoryStream stream, byte value)
        {
            stream.Append(new[] { value });
        }
    
        public static void Append(this MemoryStream stream, byte[] values)
        {
            stream.Write(values, 0, values.Length);
        }
    }
    

    Usage:

    MemoryStream stream = new MemoryStream();
    stream.Append(67);
    stream.Append(new byte[] { 68, 69 });
    byte[] data = stream.ToArray();  // gets an array with bytes 67, 68 and 69
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im sure this will be a simple one but have a project that started
This is probably a basic html/css question... I have a simple one-button form that
This is one of those things, that maybe so simple I'll never find it
I have an Asp .net page like this simple one http://issamsoft.com/app2/page1.aspx and I want
This may be simple one, but 5 mins of Googling didn't give me the
Hopefully this is a simple one, but can anyone provide some simple c# code
This should hopefully be a simple one. I would like to add an extension
I have been looking for an answer for this extensively and I am sure
I have been searching for a an answer to this for a roughly 2
I have been looking for a way to set up what I thought would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.