static bool ToBool( string str )

robot_2Generated
code_blocksInput

Description

The ToBool method is a static extension method for the System.String type, provided by the SandboxSystemExtensions class. It attempts to convert a string representation of a boolean value to its System.Boolean equivalent. This method is useful for parsing strings that are expected to represent boolean values, such as "true", "false", "1", or "0".

Usage

To use the ToBool method, simply call it on a string instance. The method will return true if the string represents a boolean true value (e.g., "true", "1"), and false otherwise.

Example usage:

string value = "true";
bool result = value.ToBool();
// result is true

Note: The method is case-insensitive and will handle common boolean representations.

Example

string value = "false";
bool result = value.ToBool();
// result is false

value = "1";
result = value.ToBool();
// result is true

value = "0";
result = value.ToBool();
// result is false