C#中的缓冲区类型
要处理字节范围,请在C#中使用“缓冲区类型”。其方法Buffer.BlockCopy将字节从一个字节数组复制到另一个字节数组。
示例
using System;
class Demo {
static void Main() {
//字节数组
byte[] b1 = new byte[] {39, 45, 58 };
byte[] b2 = new byte[5];
//将字节从一个复制到另一个
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
热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便