반응형
byte[] rv = new byte[a1.Length + a2.Length + a3.Length];
System.Buffer.BlockCopy(a1, 0, rv, 0, a1.Length);
System.Buffer.BlockCopy(a2, 0, rv, a1.Length, a2.Length);
System.Buffer.BlockCopy(a3, 0, rv, a1.Length + a2.Length, a3.Length);
IEnumerable<byte> rv = a1.Concat(a2).Concat(a3);
private byte[] Combine(params byte[][] arrays)
{
byte[] rv = new byte[arrays.Sum(a => a.Length)];
int offset = 0;
foreach (byte[] array in arrays) {
System.Buffer.BlockCopy(array, 0, rv, offset, array.Length);
offset += array.Length;
}
return rv;
}
출처 : https://stackoverflow.com/questions/415291/best-way-to-combine-two-or-more-byte-arrays-in-c-sharp
Best way to combine two or more byte arrays in C#
I have 3 byte arrays in C# that I need to combine into one. What would be the most efficient method to complete this task?
stackoverflow.com
반응형
'[====== Development ======] > C#' 카테고리의 다른 글
C# 날짜 시간 string을 DateTime으로 변환하기 (0) | 2022.11.23 |
---|---|
.Net Framework 와 .Net Core 비교 (0) | 2022.10.21 |
WPF Tutorial (0) | 2022.09.29 |
WPF ClipToBounds 속성 (자식엘레먼트가 부모를 벗어날경우에 대한 처리) (0) | 2022.09.29 |
AssemblyInfo.cs 의 버전을 변경해주는 Bat (0) | 2022.09.14 |