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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP