The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
BitConverter::ToBoolean Method (array<Byte>^, Int32)
.NET Framework (current version)
Returns a Boolean value converted from the byte at a specified position in a byte array.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
-
Type:
array<System::Byte>^
A byte array.
- startIndex
-
Type:
System::Int32
The index of the byte within value.
Return Value
Type: System::Booleantrue if the byte at startIndex in value is nonzero; otherwise, false.
| Exception | Condition |
|---|---|
| ArgumentNullException | value is null. |
| ArgumentOutOfRangeException | startIndex is less than zero or greater than the length of value minus 1. |
The following code example converts elements of Byte arrays to Boolean values with the ToBoolean method.
// Example of the BitConverter::ToBoolean method. using namespace System; int main() { // Define an array of byte values. array<Byte>^ bytes = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 255 }; Console::WriteLine("{0,5}{1,16}{2,10}\n", "index", "array element", "bool" ); // Convert each array element to a Boolean value. for (int index = 0; index < bytes->Length; index++) Console::WriteLine("{0,5}{1,16:X2}{2,10}", index, bytes[index], BitConverter::ToBoolean(bytes, index)); } // The example displays the following output: // index array element bool // // 0 00 False // 1 01 True // 2 02 True // 3 04 True // 4 08 True // 5 10 True // 6 20 True // 7 40 True // 8 80 True // 9 FF True
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: