C# 程序在数组中计算字节数
设置一个字节数组 -
byte[] b = { 5, 9, 19, 23, 29, 35, 55, 78 };
计算字节数 -
Buffer.ByteLength(b)
以下是代码 -
示例
using System; class Program { static void Main() { byte[] b = { 5, 9, 19, 23, 29, 35, 55, 78 }; int len = Buffer.ByteLength(b); for (int i = 0; i < len; i++) { Console.WriteLine(b[i]); } Console.WriteLine("Length of byte array = "+len); } }
输出
5 9 19 23 29 35 55 78 Length of byte array = 8
广告