바이트 범위를 처리하려면 C#에서 버퍼 유형을 사용하십시오. Buffer.BlockCopy 메소드는 한 바이트 배열에서 다른 바이트 배열로 바이트를 복사합니다.
예시
using System;
class Demo {
static void Main() {
// byte arrays
byte[] b1 = new byte[] {39, 45, 58 };
byte[] b2 = new byte[5];
// copying bytes from one to another
Buffer.BlockCopy(b1, 0, b2, 0, 3);
/* calling the method with the byte array b2 that has the copied elements */
bufferFunc(b2);
}
static void bufferFunc(byte[] a) {
for (int j = 0; j < a.Length; j++) {
Console.Write(a[j]);
}
Console.WriteLine();
}
} 출력
39455800