Home > Net >  How to merge multiple byte []
How to merge multiple byte []

Time:09-28

Byte [] data=https://bbs.csdn.net/topics/new byte [8000].
Like the other byte [] how to merge into the data?

CodePudding user response:

 
Byte [] b1=new byte [10].
Byte [] b2=new byte [100].
//more byte arraies
Byte [] data;
Using var (ms=new MemoryStream ())
{
Ms. Write (b1, 0, b1. Length);
Ms. Write (b2, 0, b2. Length);
Data=(https://bbs.csdn.net/topics/ms.ToArray);
}

CodePudding user response:


Using System. Linq;

Byte [] data1=new byte [8000].
Byte [] data2=new byte [2000].
Data1=data1. Concat (data2). ToArray ();

CodePudding user response:

reference 1st floor bloodish response:
 
Byte [] b1=new byte [10].
Byte [] b2=new byte [100].
//more byte arraies
Byte [] data;
Using var (ms=new MemoryStream ())
{
Ms. Write (b1, 0, b1. Length);
Ms. Write (b2, 0, b2. Length);
Data=(https://bbs.csdn.net/topics/ms.ToArray);
}

Asked how the circulation data in writing?

CodePudding user response:

 byte [] b1=new byte [1024]; 
Byte [] b2=new byte [16].
Array. Copy (b1, b2, 0, 0, b2. Length);
  •  Tags:  
  • C#
  • Related