System.Data.SqlTypes.SqlBoolean.Parse C# (CSharp) Method

Parse() public static method

public static Parse ( string s ) : SqlBoolean
s string
return SqlBoolean
        public static SqlBoolean Parse(string s)
        {
            if (null == s)
                // Let Boolean.Parse throw exception
                return new SqlBoolean(bool.Parse(s));
            if (s == SQLResource.s_nullString)
                return SqlBoolean.Null;

            s = s.TrimStart();
            char wchFirst = s[0];
            if (char.IsNumber(wchFirst) || ('-' == wchFirst) || ('+' == wchFirst))
            {
                return new SqlBoolean(int.Parse(s, null));
            }
            else
            {
                return new SqlBoolean(bool.Parse(s));
            }
        }

Usage Example

Esempio n. 1
0
 /**
  * Converts this SqlString structure to SqlBoolean.
  * @return A SqlBoolean structure whose Value will be True if the SqlString structure's Value is non-zero, False if the SqlString is zero
  * and Null if the SqlString structure is Null.
  */
 public SqlBoolean ToSqlBoolean()
 {
     return(SqlBoolean.Parse(_value));
 }