fromStringOr Summary Converts a string to its equivalent bool value or the provided default value if the conversion fails. Usage public static bool fromStringOr(string boolAsStr, bool defaultValue) Returns The bool equivalent of the string value or the provided default value if the string is not a Boolean value. Parameters boolAsStr The string value to convert. defaultValue The default value to return if the conversion fails. Description Converts a string to its equivalent bool value or the provided default value if the conversion fails. import System; bool x = Boolean.fromStringOr("true", false); Console.log(x); // true // conversion succeeded bool y = Boolean.fromStringOr("abc", false); Console.log(y); // false // conversion failed so default value returned Examples Basic Usage 123456import System; bool valid = Boolean.fromStringOr("true", false);Console.log(valid); // truebool invalid = Boolean.fromStringOr("abc", false);Console.log(invalid); // false Share HTML | BBCode | Direct Link