XmlConvert.ToBoolean Method
.NET Framework 4
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Parameters
- s
- Type: System.String
The string to convert.
| Exception | Condition |
|---|---|
| ArgumentNullException |
s is null. |
| FormatException |
s does not represent a Boolean value. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Converting 'True' or 'False' throws FormatException
It was not clear to me from this reference. Calling XmlConvert.ToBoolean with 'True' or 'False' instead of 'true' or 'false' throws FormatException. Can be handled by converting the input string to lowercase before calling this method. It will be really nice if the method took care of this.
- 5/2/2012
- Sumit S