Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# program to count number of bytes in an array
Set a byte array −
byte[] b = { 5, 9, 19, 23, 29, 35, 55, 78 };
To count number of bytes −
Buffer.ByteLength(b)
The following is the code −
Example
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);
}
}
Output
5 9 19 23 29 35 55 78 Length of byte array = 8
Advertisements
