TopicTransformationExtensionsToBoolean 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: 2024.9.12.0
public static bool ToBoolean(
	this XAttribute attribute
)

Parameters

attribute  XAttribute
The attribute to convert

Return Value

Boolean
The 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.

See Also