C#에서 GetByte() 메서드를 사용하여 개별 바이트 읽기 −
배열 설정 -
int[] arr = { 3, 4, 12 }; 이제 Buffer.GetByte()를 사용하여 배열 요소를 표시하고 개별 바이트를 읽습니다 -
for (int i = 0; i < Buffer.ByteLength(arr); i++) {
Console.WriteLine(Buffer.GetByte(arr, i));
} 다음은 코드입니다 -
예시
using System;
using System.Text;
public class Demo {
public static void Main() {
int[] arr = { 3, 4, 12 };
// loop through the byte array
for (int i = 0; i < Buffer.ByteLength(arr); i++) {
Console.WriteLine(Buffer.GetByte(arr, i));
}
}
} 출력
3 0 0 0 4 0 0 0 12 0 0 0