using
System;
using
System.Globalization;
class
GFG {
public
static
void
Main()
{
try
{
CultureInfo cultures =
new
CultureInfo(
"en-US"
);
String[] values = {
null
,
"true"
,
"False"
,
" false "
,
""
};
Console.WriteLine(
"Converted bool value"
+
" of specified strings: "
);
for
(
int
j = 0; j < values.Length; j++) {
get
(values[j], cultures);
}
}
catch
(FormatException e) {
Console.WriteLine(
"\n"
);
Console.Write(
"Exception Thrown: "
);
Console.Write(
"{0}"
, e.GetType(), e.Message);
}
}
public
static
void
get
(
string
s, CultureInfo cultures)
{
bool
val = Convert.ToBoolean(s, cultures);
Console.Write(
" {0}, "
, val);
}
}