using
System;
class
GFG {
public
static
void
Main()
{
try
{
byte
[] bytes = { 0, 1, 2, 4, 8, 16, 32, 64 };
Console.Write(
"Initial Array: "
);
PrintIndexAndValues(bytes);
for
(
int
index = 0; index < bytes.Length; index++) {
bool
values = BitConverter.ToBoolean(bytes, index);
Console.WriteLine(
"index element bool"
);
Console.WriteLine(
" {0} {1} {2}"
,
index, bytes[index], values);
}
}
catch
(ArgumentNullException e) {
Console.Write(
"Exception Thrown: "
);
Console.Write(
"{0}"
, e.GetType(), e.Message);
}
catch
(ArgumentOutOfRangeException e) {
Console.Write(
"Exception Thrown: "
);
Console.Write(
"{0}"
, e.GetType(), e.Message);
}
}
public
static
void
PrintIndexAndValues(
byte
[] myArr)
{
for
(
int
i = 0; i < myArr.Length; i++) {
Console.Write(
"{0} "
, myArr[i]);
}
Console.WriteLine();
Console.WriteLine();
}
}