निर्दिष्ट मान को समतुल्य बूलियन मान में बदलने के लिए, कोड इस प्रकार है -
उदाहरण
using System;
using System.Globalization;
public class Demo {
public static void Main() {
CultureInfo cultures = new CultureInfo("en-US");
String str = "true";
Console.WriteLine("Converted bool value...");
bool res = Convert.ToBoolean(str, cultures);
Console.Write("{0}", res);
}
} आउटपुट
यह निम्नलिखित आउटपुट देगा -
Converted bool value... True
उदाहरण
आइए एक और उदाहरण देखें -
using System;
using System.Globalization;
public class Demo {
public static void Main() {
CultureInfo cultures = new CultureInfo("es-ES", false);
String str = "false";
Console.WriteLine("Converted bool value...");
bool res = Convert.ToBoolean(str, cultures);
Console.Write("{0}", res);
}
} आउटपुट
यह निम्नलिखित आउटपुट देगा -
Converted bool value... False