StringExtensions.ParseBoolean method

Version 1.1.28
.NET Framework 4.8
Namespace Skybrud.Essentials.Strings.Extensions
Assembly Skybrud.Essentials.dll

ParseBoolean(string, bool)

Extension method

Converts str into an instance of bool . The input string is considered true if it matches either true, 1, t or on, or false if it matches either false, 0, f or off. All comparisons are case insensitive.

public static bool ParseBoolean(this string str, bool fallback)

Parameters

str String

The string to be parsed.

fallback bool

The fallback value.

Returns

true if str matches either true, 1, t or on, false if str matches either false, 0, f or off. For all other values, fallback is returned instead.