Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Equivalent to StringBuilder for bytes?

Posted on 2007-04-03
3
Medium Priority
?
2,077 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 2000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

715 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