System.Xml.XmlConverter.ToBoolean C# (CSharp) Method

ToBoolean() static public method

static public ToBoolean ( string value ) : bool
value string
return bool
        static public bool ToBoolean(string value)
        {
            try
            {
                return XmlConvert.ToBoolean(value);
            }
            catch (ArgumentException exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value, "Boolean", exception));
            }
            catch (FormatException exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value, "Boolean", exception));
            }
        }

Same methods

XmlConverter::ToBoolean ( byte buffer, int offset, int count ) : bool

Usage Example

示例#1
0
        public bool ToBoolean()
        {
            ValueHandleType type = _type;

            if (type == ValueHandleType.False)
            {
                return(false);
            }
            if (type == ValueHandleType.True)
            {
                return(true);
            }
            if (type == ValueHandleType.UTF8)
            {
                return(XmlConverter.ToBoolean(_bufferReader.Buffer, _offset, _length));
            }
            if (type == ValueHandleType.Int8)
            {
                int value = GetInt8();
                if (value == 0)
                {
                    return(false);
                }
                if (value == 1)
                {
                    return(true);
                }
            }
            return(XmlConverter.ToBoolean(GetString()));
        }
All Usage Examples Of System.Xml.XmlConverter::ToBoolean