
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Buffer GetByte Example in C#
Read individual bytes using GetByte() method in C# −
Set an array −
int[] arr = { 3, 4, 12 };
Now, use Buffer.GetByte() to display the array elements and to read individual bytes −
for (int i = 0; i < Buffer.ByteLength(arr); i++) { Console.WriteLine(Buffer.GetByte(arr, i)); }
The following is the code −
Example
using System; using System.Text; public class Demo { public static void Main() { int[] arr = { 3, 4, 12 }; // loop through the byte array for (int i = 0; i < Buffer.ByteLength(arr); i++) { Console.WriteLine(Buffer.GetByte(arr, i)); } } }
Output
3 0 0 0 4 0 0 0 12 0 0 0
Advertisements