Topic Transformation ExtensionsTo Boolean Method
This converts an attribute value to a Boolean value. If not present, blank, or invalid, it
returns false.
Definition
Namespace: Sandcastle.Core.PresentationStyle.Transformation
Assembly: Sandcastle.Core (in Sandcastle.Core.dll) Version: 2026.1.20.0
The attribute value if it is a Boolean or false if not
Assembly: Sandcastle.Core (in Sandcastle.Core.dll) Version: 2026.1.20.0
C#
public static bool ToBoolean(
this XAttribute attribute
)VB
<ExtensionAttribute>
Public Shared Function ToBoolean (
attribute As XAttribute
) As BooleanC++
public:
[ExtensionAttribute]
static bool ToBoolean(
XAttribute^ attribute
)F#
[<ExtensionAttribute>]
static member ToBoolean :
attribute : XAttribute -> bool Parameters
- attribute XAttribute
- The attribute to convert
Return Value
BooleanThe attribute value if it is a Boolean or false if not
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type XAttribute. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Remarks
Explicit casting of an attribute to bool or bool? works but if the value is
invalid or blank, the cast throws an exception. This will return false in those cases too.