C# में BitConverter.ToBoolean() विधि एक बाइट सरणी में एक निर्दिष्ट स्थान पर बाइट से परिवर्तित एक बूलियन मान देता है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
public static bool ToBoolean (byte[] arr, int startIndex);
ऊपर, गिरफ्तारी एक बाइट सरणी है, जबकि 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