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