# ToBool(Boolean)

{% code title="Declaration" %}

```csharp
public static bool ToBool(this object value, bool safe = true)
```

{% endcode %}

{% code title="Example" %}

```csharp
object validObjectInt = 1;
object validObjectString = "1";
object invalidObjectString = "Hello";
object invalidObjectDouble = 1.234d;

validObjectInt.ToBool(true);
validObjectInt.ToBool(false);

validObjectString.ToBool(true);
validObjectString.ToBool(false);

invalidObjectString.ToBool(true);
invalidObjectDouble.ToBool(true).Should().Be(false);

invalidObjectString.ToBool(false);
invalidObjectDouble.ToBool(false);
```

{% endcode %}

{% code title="Result" %}

```csharp
true
true

true
true

false
false

ArgumentException
ArgumentException
```

{% endcode %}
