C#의 BitConverter.ToBoolean() 메서드는 바이트 배열의 지정된 위치에 있는 바이트에서 변환된 부울 값을 반환합니다.
구문
다음은 구문입니다 -
public static bool ToBoolean (byte[] arr, int startIndex);
위에서 arr은 바이트 배열이고 startIndex는 값 내 바이트의 인덱스입니다.
예시
이제 BitConverter.ToBoolean() 메서드를 구현하는 예를 살펴보겠습니다. -
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);
}
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Array values... 50 100 Converted values... True True