Solved

Equivalent to StringBuilder for bytes?

Posted on 2007-04-03
3
2,066 Views
Last Modified: 2013-11-07
Is there an equivalent to the StringBuilder class for writing values which are automatically converted to a byte array and then added to an internal byte array?
Example:

ByteBuilder bb = new ByteBuilder();
bb.Write(1.0f);
bb.Write(false);
bb.Write(3.1);
return bb.AllBytes();

Note: This class ByteBuilder, I'm searching for an equivalent IN the .net Framework.
0
Comment
Question by:makronium
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Expert Comment

by:Babycorn-Starfish
ID: 18842889
Hi,

you could certainly make one but i've never seen something like you've outlined in the .NET framework - hopefully one exists though and its just obscure.

Best of luck
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18842905
nothing built-in.

found this project that has a class coded:
http://www.codeproject.com/csharp/lobby.asp?df=100&forumid=302662&exp=0&select=1681995
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 18845006
might have accepted too quickly .. would a MemoryStream and a BinaryWriter not do just this? :)

http://msdn2.microsoft.com/en-us/library/system.io.binarywriter.aspx

MemoryStream m = new MemoryStream();
BinaryWriter writer = new BinaryWriter(m);
writer.write(true);
writer.write("hello");
writer.write(12345);
writer.Flush();
return m.ToArray();
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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