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
BitConverter.ToBoolean() Method in C#
The BitConverter.ToBoolean() method in C# returns a Boolean value converted from the byte at a specified position in a byte array.
Syntax
Following is the syntax −
public static bool ToBoolean (byte[] arr, int startIndex);
Above, arr is a byte array, whereas startIndex is the index of the byte within a value.
Example
Let us now see an example to implement the BitConverter.ToBoolean() method −
using System;
public class Demo {
public static void Main(){
byte[] arr = { 50, 100 };
Console.WriteLine("Array values...");
for (int i = 0; i < arr.Length; i++) {
Console.WriteLine("{0} ", arr[i]);
}
Console.WriteLine("\nConverted values...");
for (int index = 0; index < arr.Length; index++) {
bool res = BitConverter.ToBoolean(arr, index);
Console.WriteLine(""+res);
}
}
}
Output
This will produce the following output −
Array values... 50 100 Converted values... True True
Advertisements
