What is the simplest way to combine one byte[] with another?
for example if i have
byte[] header = Encoding.ASCII. GetBytes("this is the header");
and
byte[] body = Encoding.ASCII. GetBytes("this is the body");
how can i combined them into one?
TIA,
Vinny 3 1839
"Vinny Vinn" <Vi*******@disc ussions.microso ft.com> wrote in message
news:84******** *************** ***********@mic rosoft.com... What is the simplest way to combine one byte[] with another? for example if i have byte[] header = Encoding.ASCII. GetBytes("this is the header"); and byte[] body = Encoding.ASCII. GetBytes("this is the body"); how can i combined them into one?
TIA, Vinny
:) Here is one way.
byte[] header = System.Text.Enc oding.ASCII.Get Bytes(
"this is the header"
);
byte[] body = System.Text.Enc oding.ASCII.Get Bytes(
"this is the body"
);
byte[] contents = new byte[header.Length + body.Length];
Array.Copy(head er, 0, contents, 0, header.Length);
Array.Copy(body , 0, contents, header.Length, body.Length);
string s = System.Text.Enc oding.ASCII.Get String(contents );
Console.WriteLi ne(s);
HTH
Mythran
I suppose you mean 'concat' the two buffers ?
byte[] concatBuffer = new byte[header.Length + body.Length];
Buffer.BlockCop y(header, 0, concatBuffer, 0, header.Length);
Buffer.BlockCop y(body, 0, concatBuffer, header.Length, body.Length);
"Vinny Vinn" wrote: What is the simplest way to combine one byte[] with another? for example if i have byte[] header = Encoding.ASCII. GetBytes("this is the header"); and byte[] body = Encoding.ASCII. GetBytes("this is the body"); how can i combined them into one?
TIA, Vinny
Thank you Mythran and Luc
"Vinny Vinn" wrote: What is the simplest way to combine one byte[] with another? for example if i have byte[] header = Encoding.ASCII. GetBytes("this is the header"); and byte[] body = Encoding.ASCII. GetBytes("this is the body"); how can i combined them into one?
TIA, Vinny This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: kee |
last post by:
Hi All,
I am trying to figure out on how to combine 2 byte array and save to a file.
e.g.
open "image001.bmp" for binary access write as #1
put #1,,x() & y()
close #1
notes : x() and y() contains bitmap binary data.
|
by: Nick |
last post by:
I am working a new application...well actually a series of applications for
my company. They want internal users to be able to go to a site and
everything regarding security is transparent, however we will have brokers
and customers that also need to connect and will require a username and
password. In this case we were going to store their credentials in a SQL
database. Internal users will have the ability to access the same resources...
|
by: TJO |
last post by:
What is the best way to combine two byte? I am not finding one yet.
Thanks
|
by: trint |
last post by:
add them into one PrintDocument:
PrintDocument pd1 = new PrintDocument();
PrintDocument pd2 = new PrintDocument();
PrintDocument pdCombined = new PrintDocument();
pdCombined = pd1 + pd2;
pdCombined.Print();
Thanks,
Trint
|
by: William Stacey [MVP] |
last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ
rooted path (similar to a VDir in IIS). Path.Combine alone will not do the
job in all cases. I also need to be sure the no funny business can go on in
the passed "path" that would produce a path not in the root (i.e.
"..\..\dir1"). Here is my first stab at it, but not sure if this is too
much or not enouph to ensure this. Any thoughts are welcome. TIA.
///...
| |
by: frekster |
last post by:
Hi.
I used to be able to do this easily in vb 6 via looping and preserving
the source array data/size etc.
How can I do this in vb.net? I've been trying for a while now and this
should be an easy task but it just isn't clicking.
For some reason, the preserve doesn't seem to be working.
|
by: Schroeder, AJ |
last post by:
Hello group,
I am a relative PHP newbie and I am trying to combine two arrays together,
but I also need to keep the keys of one array intact. What I am doing is two
SNMP walks against a Cisco router in which I expect the script to return the
interface number along with a small description of the interface type, like
this:
Array
(
|
by: nugz |
last post by:
I want to combine 3 tables with like data then append it with a filter.
Tables: NewStarts, Complaints, Memos
Combine: Date, Address, Route, Pub, etc....
Then sort: previous 8 days, pub/freq for that day etc...
I can already do the append filter, but I cant combine and then append.
I tried a Union and did the combine.. but lack the part to append the union.
|
by: chris |
last post by:
I have a few byte arrays that I would like to combine into one array
(order needs to be kept). What would be the most efficient way to do
this?
Thanks for your time,
Chris
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |