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
Buffer Type in C#
To handle range of bytes, use Buffer Type in C#. Its method Buffer.BlockCopy copies the bytes from one byte array to another byte array.
Example
using System;
class Demo {
static void Main() {
// byte arrays
byte[] b1 = new byte[] {39, 45, 58 };
byte[] b2 = new byte[5];
// copying bytes from one to another
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();
}
}
Output
39455800
Advertisements
