# SqlDecimalSqlDecimalSqlDecimalSqlDecimal Struct

## 定义

``public value class SqlDecimal : IComparable, System::Data::SqlTypes::INullable, System::Xml::Serialization::IXmlSerializable``
``````[System.Serializable]
public struct SqlDecimal : IComparable, System.Data.SqlTypes.INullable, System.Xml.Serialization.IXmlSerializable``````
``````type SqlDecimal = struct
interface INullable
interface IXmlSerializable``````
``````Public Structure SqlDecimal
Implements IComparable, INullable, IXmlSerializable``````

SqlDecimalSqlDecimalSqlDecimalSqlDecimal

## 注解

SqlDecimal 已从其相应的.NET Framework 的不同基础数据结构Decimal数据类型。SqlDecimal has different underlying data structures from its corresponding .NET Framework Decimal data type. Decimal 有没有精度的概念。Decimal has no concept of precision. 它使用 3 个字节来存储实际数据，因此具有最大小数位数为 28。It uses 3 bytes to store the actual data, and therefore has a maximum scale of 28. 数据范围是-79228162514264337593543950335 到 79228162514264337593543950335。The data range is -79,228,162,514,264,337,593,543,950,335 through 79,228,162,514,264,337,593,543,950,335. SqlDecimal 具有精度和小数位数。SqlDecimal has both precision and scale. 它使用 4 个 4 字节无符号的整数来存储实际数据，并因此具有最大精度和小数位数为 38。It uses 4 unsigned 4-byte integers to store the actual data, and therefore has maximum precision and scale of 38. 数据范围为-10 ^38 + 1 到 10 ^38-1。The data range is - 10^38 +1 through 10^38 - 1.

## 构造函数

 SqlDecimal(Decimal) SqlDecimal(Decimal) SqlDecimal(Decimal) SqlDecimal(Decimal) 使用提供的 SqlDecimal 值初始化 Decimal 结构的新实例。Initializes a new instance of the SqlDecimal structure using the supplied Decimal value. SqlDecimal(Double) SqlDecimal(Double) SqlDecimal(Double) SqlDecimal(Double) 使用提供的 double 类型的参数初始化 SqlDecimal 结构的新实例。Initializes a new instance of the SqlDecimal structure using the supplied double parameter. SqlDecimal(Int32) SqlDecimal(Int32) SqlDecimal(Int32) SqlDecimal(Int32) 使用提供的整数值初始化 SqlDecimal 结构的新实例。Initializes a new instance of the SqlDecimal structure using the supplied integer value. SqlDecimal(Int64) SqlDecimal(Int64) SqlDecimal(Int64) SqlDecimal(Int64) 使用提供的长整数值初始化 SqlDecimal 结构的新实例。Initializes a new instance of the SqlDecimal structure using the supplied long integer value. SqlDecimal(Byte, Byte, Boolean, Int32[]) SqlDecimal(Byte, Byte, Boolean, Int32[]) SqlDecimal(Byte, Byte, Boolean, Int32[]) SqlDecimal(Byte, Byte, Boolean, Int32[]) 使用提供的参数初始化 SqlDecimal 结构的新实例。Initializes a new instance of the SqlDecimal structure using the supplied parameters. SqlDecimal(Byte, Byte, Boolean, Int32, Int32, Int32, Int32) SqlDecimal(Byte, Byte, Boolean, Int32, Int32, Int32, Int32) SqlDecimal(Byte, Byte, Boolean, Int32, Int32, Int32, Int32) SqlDecimal(Byte, Byte, Boolean, Int32, Int32, Int32, Int32) 使用提供的参数初始化 SqlDecimal 结构的新实例。Initializes a new instance of the SqlDecimal structure using the supplied parameters.

## 字段

 MaxPrecision MaxPrecision MaxPrecision MaxPrecision 一个常数，它表示 Precision 属性的可能的最大值。A constant representing the largest possible value for the Precision property. MaxScale MaxScale MaxScale MaxScale 一个常数，它表示 Scale 属性的最大值。A constant representing the maximum value for the Scale property. MaxValue MaxValue MaxValue MaxValue 一个常数，它表示 SqlDecimal 结构的最大值。A constant representing the maximum value of a SqlDecimal structure. MinValue MinValue MinValue MinValue 一个常数，它表示 SqlDecimal 结构的最小值。A constant representing the minimum value for a SqlDecimal structure. Null Null Null Null 表示可指派给 DBNull 类的此实例的 SqlDecimal。Represents a DBNull that can be assigned to this instance of the SqlDecimal class.

## 属性

 BinData BinData BinData BinData 以字节数组形式获取此 SqlDecimal 结构的值的二进制表示形式。Gets the binary representation of the value of this SqlDecimal structure as an array of bytes. Data Data Data Data 以整数数组形式获取此 SqlDecimal 结构的二进制表示形式。Gets the binary representation of this SqlDecimal structure as an array of integers. IsNull IsNull IsNull IsNull 指示此 SqlDecimal 结构是否为 null。Indicates whether this SqlDecimal structure is null. IsPositive IsPositive IsPositive IsPositive 指示此 Value 结构的 SqlDecimal 是否大于零。Indicates whether the Value of this SqlDecimal structure is greater than zero. Precision Precision Precision Precision 获取用于表示 Value 属性的最大位数。Gets the maximum number of digits used to represent the Value property. Scale Scale Scale Scale 获取 Value 解析为的小数位数。Gets the number of decimal places to which Value is resolved. Value Value Value Value 获取 SqlDecimal 结构的值。Gets the value of the SqlDecimal structure. 此属性是只读的。This property is read-only.

## 方法

 Abs(SqlDecimal) Abs(SqlDecimal) Abs(SqlDecimal) Abs(SqlDecimal) Abs 方法获取 SqlDecimal 参数的绝对值。The Abs method gets the absolute value of the SqlDecimal parameter. Add(SqlDecimal, SqlDecimal) Add(SqlDecimal, SqlDecimal) Add(SqlDecimal, SqlDecimal) Add(SqlDecimal, SqlDecimal) 计算两个 SqlDecimal 操作数的和。Calculates the sum of the two SqlDecimal operators. AdjustScale(SqlDecimal, Int32, Boolean) AdjustScale(SqlDecimal, Int32, Boolean) AdjustScale(SqlDecimal, Int32, Boolean) AdjustScale(SqlDecimal, Int32, Boolean) 将 SqlDecimal 操作数的小数位数调整为位数参数指示的位数。The scale of the SqlDecimal operand will be adjusted to the number of digits indicated by the digits parameter. 取决于 fRound 参数的值，该值将舍入到适当的位数或者截断。Depending on the value of the fRound parameter, the value will either be rounded to the appropriate number of digits or truncated. Ceiling(SqlDecimal) Ceiling(SqlDecimal) Ceiling(SqlDecimal) Ceiling(SqlDecimal) 返回大于或等于指定 SqlDecimal 结构的最小整数。Returns the smallest whole number greater than or equal to the specified SqlDecimal structure. CompareTo(SqlDecimal) CompareTo(SqlDecimal) CompareTo(SqlDecimal) CompareTo(SqlDecimal) 将此 SqlDecimal 实例与所提供的 SqlDecimal 对象进行比较，并返回其相对值的指示值。Compares this SqlDecimal instance to the supplied SqlDecimal object and returns an indication of their relative values. CompareTo(Object) CompareTo(Object) CompareTo(Object) CompareTo(Object) 将此 SqlDecimal 实例与所提供的 Object 进行比较，并返回二者相对值的指示值。Compares this SqlDecimal instance to the supplied Object and returns an indication of their relative values. ConvertToPrecScale(SqlDecimal, Int32, Int32) ConvertToPrecScale(SqlDecimal, Int32, Int32) ConvertToPrecScale(SqlDecimal, Int32, Int32) ConvertToPrecScale(SqlDecimal, Int32, Int32) 将 SqlDecimal 操作数的值调整为指定精度和小数位数。Adjusts the value of the SqlDecimal operand to the indicated precision and scale. Divide(SqlDecimal, SqlDecimal) Divide(SqlDecimal, SqlDecimal) Divide(SqlDecimal, SqlDecimal) Divide(SqlDecimal, SqlDecimal) 该除法运算符计算将第一个 SqlDecimal 操作数除以第二个操作数所得的结果。The division operator calculates the results of dividing the first SqlDecimal operand by the second. Equals(Object) Equals(Object) Equals(Object) Equals(Object) 将提供的 Object 参数与 Value 实例的 SqlDecimal 属性进行比较。Compares the supplied Object parameter to the Value property of the SqlDecimal instance. Equals(SqlDecimal, SqlDecimal) Equals(SqlDecimal, SqlDecimal) Equals(SqlDecimal, SqlDecimal) Equals(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 操作数执行逻辑比较，以确定它们是否相等。Performs a logical comparison of the two SqlDecimal operands to determine whether they are equal. Floor(SqlDecimal) Floor(SqlDecimal) Floor(SqlDecimal) Floor(SqlDecimal) 将指定 SqlDecimal 数字舍入为下一个较小的整数。Rounds a specified SqlDecimal number to the next lower whole number. GetHashCode() GetHashCode() GetHashCode() GetHashCode() 返回此实例的哈希代码。Returns the hash code for this instance. GetXsdType(XmlSchemaSet) GetXsdType(XmlSchemaSet) GetXsdType(XmlSchemaSet) GetXsdType(XmlSchemaSet) 返回指定的 XmlSchemaSet 的 XML 架构定义语言 (XSD)。Returns the XML Schema definition language (XSD) of the specified XmlSchemaSet. GreaterThan(SqlDecimal, SqlDecimal) GreaterThan(SqlDecimal, SqlDecimal) GreaterThan(SqlDecimal, SqlDecimal) GreaterThan(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 结构执行逻辑比较，以确定第一个结构是否大于第二个结构。Performs a logical comparison of two SqlDecimal structures to determine whether the first is greater than the second. GreaterThanOrEqual(SqlDecimal, SqlDecimal) GreaterThanOrEqual(SqlDecimal, SqlDecimal) GreaterThanOrEqual(SqlDecimal, SqlDecimal) GreaterThanOrEqual(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 参数执行逻辑比较，以确定第一个参数是否大于或等于第二个参数。Performs a logical comparison of the two SqlDecimal parameters to determine whether the first is greater than or equal to the second. LessThan(SqlDecimal, SqlDecimal) LessThan(SqlDecimal, SqlDecimal) LessThan(SqlDecimal, SqlDecimal) LessThan(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 结构执行逻辑比较，以确定第一个结构是否小于第二个结构。Performs a logical comparison of two SqlDecimal structures to determine whether the first is less than the second. LessThanOrEqual(SqlDecimal, SqlDecimal) LessThanOrEqual(SqlDecimal, SqlDecimal) LessThanOrEqual(SqlDecimal, SqlDecimal) LessThanOrEqual(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 参数执行逻辑比较，以确定第一个参数是否小于或等于第二个参数。Performs a logical comparison of the two SqlDecimal parameters to determine whether the first is less than or equal to the second. Multiply(SqlDecimal, SqlDecimal) Multiply(SqlDecimal, SqlDecimal) Multiply(SqlDecimal, SqlDecimal) Multiply(SqlDecimal, SqlDecimal) 该乘法运算符计算两个 SqlDecimal 参数的乘积。The multiplication operator computes the product of the two SqlDecimal parameters. NotEquals(SqlDecimal, SqlDecimal) NotEquals(SqlDecimal, SqlDecimal) NotEquals(SqlDecimal, SqlDecimal) NotEquals(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 参数执行逻辑比较，确定它们是否不相等。Performs a logical comparison of the two SqlDecimal parameters to determine whether they are not equal. Parse(String) Parse(String) Parse(String) Parse(String) 将数字的 String 表示形式转换为其等效的 SqlDecimal 形式。Converts the String representation of a number to its SqlDecimal equivalent. Power(SqlDecimal, Double) Power(SqlDecimal, Double) Power(SqlDecimal, Double) Power(SqlDecimal, Double) 将指定的 SqlDecimal 结构的值乘到指定的幂。Raises the value of the specified SqlDecimal structure to the specified exponential power. Round(SqlDecimal, Int32) Round(SqlDecimal, Int32) Round(SqlDecimal, Int32) Round(SqlDecimal, Int32) 以指定精度获取与指定 SqlDecimal 结构的值最接近的数字。Gets the number nearest the specified SqlDecimal structure's value with the specified precision. Sign(SqlDecimal) Sign(SqlDecimal) Sign(SqlDecimal) Sign(SqlDecimal) 获取一个值，该值指示 SqlDecimal 结构的 Value 属性的符号。Gets a value that indicates the sign of a SqlDecimal structure's Value property. Subtract(SqlDecimal, SqlDecimal) Subtract(SqlDecimal, SqlDecimal) Subtract(SqlDecimal, SqlDecimal) Subtract(SqlDecimal, SqlDecimal) 计算从第一个 SqlDecimal 操作数中减去第二个操作数所得的结果。Calculates the results of subtracting the second SqlDecimal operand from the first. ToDouble() ToDouble() ToDouble() ToDouble() 返回等于此实例的 Value 属性的内容的双精度型值。Returns the a double equal to the contents of the Value property of this instance. ToSqlBoolean() ToSqlBoolean() ToSqlBoolean() ToSqlBoolean() 将此 SqlDecimal 结构转换为 SqlBoolean。Converts this SqlDecimal structure to SqlBoolean. ToSqlByte() ToSqlByte() ToSqlByte() ToSqlByte() 将此 SqlDecimal 结构转换为 SqlByte。Converts this SqlDecimal structure to SqlByte. ToSqlDouble() ToSqlDouble() ToSqlDouble() ToSqlDouble() 将此 SqlDecimal 结构转换为 SqlDouble。Converts this SqlDecimal structure to SqlDouble. ToSqlInt16() ToSqlInt16() ToSqlInt16() ToSqlInt16() 将此 SqlDecimal 结构转换为 SqlInt16。Converts this SqlDecimal structure to SqlInt16. ToSqlInt32() ToSqlInt32() ToSqlInt32() ToSqlInt32() 将此 SqlDecimal 结构转换为 SqlInt32。Converts this SqlDecimal structure to SqlInt32. ToSqlInt64() ToSqlInt64() ToSqlInt64() ToSqlInt64() 将此 SqlDecimal 结构转换为 SqlInt64。Converts this SqlDecimal structure to SqlInt64. ToSqlMoney() ToSqlMoney() ToSqlMoney() ToSqlMoney() 将此 SqlDecimal 结构转换为 SqlMoney。Converts this SqlDecimal structure to SqlMoney. ToSqlSingle() ToSqlSingle() ToSqlSingle() ToSqlSingle() 将此 SqlDecimal 结构转换为 SqlSingle。Converts this SqlDecimal structure to SqlSingle. ToSqlString() ToSqlString() ToSqlString() ToSqlString() 将此 SqlDecimal 结构转换为 SqlString。Converts this SqlDecimal structure to SqlString. ToString() ToString() ToString() ToString() 将此 SqlDecimal 结构转换为 String。Converts this SqlDecimal structure to String. Truncate(SqlDecimal, Int32) Truncate(SqlDecimal, Int32) Truncate(SqlDecimal, Int32) Truncate(SqlDecimal, Int32) 将指定 SqlDecimal 结构的值截断到希望的位置。Truncates the specified SqlDecimal structure's value to the that you want position.

## 操作员

 Addition(SqlDecimal, SqlDecimal) Addition(SqlDecimal, SqlDecimal) Addition(SqlDecimal, SqlDecimal) Addition(SqlDecimal, SqlDecimal) 计算两个 SqlDecimal 操作数的和。Calculates the sum of the two SqlDecimal operators. Division(SqlDecimal, SqlDecimal) Division(SqlDecimal, SqlDecimal) Division(SqlDecimal, SqlDecimal) Division(SqlDecimal, SqlDecimal) 该除法运算符计算将第一个 SqlDecimal 操作数除以第二个操作数所得的结果。The division operator calculates the results of dividing the first SqlDecimal operand by the second. Equality(SqlDecimal, SqlDecimal) Equality(SqlDecimal, SqlDecimal) Equality(SqlDecimal, SqlDecimal) Equality(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 操作数执行逻辑比较，以确定它们是否相等。Performs a logical comparison of the two SqlDecimal operands to determine whether they are equal. Explicit(Double to SqlDecimal) Explicit(Double to SqlDecimal) Explicit(Double to SqlDecimal) Explicit(Double to SqlDecimal) 将 Double 参数转换为 SqlDecimal。Converts the Double parameter to SqlDecimal. Explicit(SqlString to SqlDecimal) Explicit(SqlString to SqlDecimal) Explicit(SqlString to SqlDecimal) Explicit(SqlString to SqlDecimal) 将提供的 SqlString 参数转换为 SqlDecimal。Converts the supplied SqlString parameter to SqlDecimal. Explicit(SqlSingle to SqlDecimal) Explicit(SqlSingle to SqlDecimal) Explicit(SqlSingle to SqlDecimal) Explicit(SqlSingle to SqlDecimal) 将提供的 SqlSingle 结构转换为 SqlDecimal。Converts the supplied SqlSingle structure to SqlDecimal. Explicit(SqlDecimal to Decimal) Explicit(SqlDecimal to Decimal) Explicit(SqlDecimal to Decimal) Explicit(SqlDecimal to Decimal) 将 SqlDecimal 参数转换为 Decimal。Converts the SqlDecimal parameter to Decimal. Explicit(SqlBoolean to SqlDecimal) Explicit(SqlBoolean to SqlDecimal) Explicit(SqlBoolean to SqlDecimal) Explicit(SqlBoolean to SqlDecimal) 将提供的 SqlBoolean 结构转换为 SqlDecimal。Converts the supplied SqlBoolean structure to SqlDecimal. Explicit(SqlDouble to SqlDecimal) Explicit(SqlDouble to SqlDecimal) Explicit(SqlDouble to SqlDecimal) Explicit(SqlDouble to SqlDecimal) 将提供的 SqlDouble 结构转换为 SqlDecimal。Converts the supplied SqlDouble structure to SqlDecimal. GreaterThan(SqlDecimal, SqlDecimal) GreaterThan(SqlDecimal, SqlDecimal) GreaterThan(SqlDecimal, SqlDecimal) GreaterThan(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 结构执行逻辑比较，以确定第一个结构是否大于第二个结构。Performs a logical comparison of two SqlDecimal structures to determine whether the first is greater than the second. GreaterThanOrEqual(SqlDecimal, SqlDecimal) GreaterThanOrEqual(SqlDecimal, SqlDecimal) GreaterThanOrEqual(SqlDecimal, SqlDecimal) GreaterThanOrEqual(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 参数执行逻辑比较，以确定第一个参数是否大于或等于第二个参数。Performs a logical comparison of the two SqlDecimal parameters to determine whether the first is greater than or equal to the second. Implicit(SqlMoney to SqlDecimal) Implicit(SqlMoney to SqlDecimal) Implicit(SqlMoney to SqlDecimal) Implicit(SqlMoney to SqlDecimal) 将 SqlMoney 操作数转换为 SqlDecimal。Converts the SqlMoney operand to SqlDecimal. Implicit(Int64 to SqlDecimal) Implicit(Int64 to SqlDecimal) Implicit(Int64 to SqlDecimal) Implicit(Int64 to SqlDecimal) 将提供的 Int64 结构转换为 SqlDecimal。Converts the supplied Int64 structure to SqlDecimal. Implicit(Decimal to SqlDecimal) Implicit(Decimal to SqlDecimal) Implicit(Decimal to SqlDecimal) Implicit(Decimal to SqlDecimal) 将 Decimal 值转换为 SqlDecimal。Converts the Decimal value to SqlDecimal. Implicit(SqlInt64 to SqlDecimal) Implicit(SqlInt64 to SqlDecimal) Implicit(SqlInt64 to SqlDecimal) Implicit(SqlInt64 to SqlDecimal) 将提供的 SqlInt64 结构转换为 SqlDecimal。Converts the supplied SqlInt64 structure to SqlDecimal. Implicit(SqlInt32 to SqlDecimal) Implicit(SqlInt32 to SqlDecimal) Implicit(SqlInt32 to SqlDecimal) Implicit(SqlInt32 to SqlDecimal) 将提供的 SqlInt32 结构转换为 SqlDecimal。Converts the supplied SqlInt32 structure to SqlDecimal. Implicit(SqlInt16 to SqlDecimal) Implicit(SqlInt16 to SqlDecimal) Implicit(SqlInt16 to SqlDecimal) Implicit(SqlInt16 to SqlDecimal) 将提供的 SqlInt16 结构转换为 SqlDecimal。Converts the supplied SqlInt16 structure to SqlDecimal Implicit(SqlByte to SqlDecimal) Implicit(SqlByte to SqlDecimal) Implicit(SqlByte to SqlDecimal) Implicit(SqlByte to SqlDecimal) 将提供的 SqlByte 结构转换为 SqlDecimal。Converts the supplied SqlByte structure to SqlDecimal. Inequality(SqlDecimal, SqlDecimal) Inequality(SqlDecimal, SqlDecimal) Inequality(SqlDecimal, SqlDecimal) Inequality(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 参数执行逻辑比较，确定它们是否不相等。Performs a logical comparison of the two SqlDecimal parameters to determine whether they are not equal. LessThan(SqlDecimal, SqlDecimal) LessThan(SqlDecimal, SqlDecimal) LessThan(SqlDecimal, SqlDecimal) LessThan(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 结构执行逻辑比较，以确定第一个结构是否小于第二个结构。Performs a logical comparison of two SqlDecimal structures to determine whether the first is less than the second. LessThanOrEqual(SqlDecimal, SqlDecimal) LessThanOrEqual(SqlDecimal, SqlDecimal) LessThanOrEqual(SqlDecimal, SqlDecimal) LessThanOrEqual(SqlDecimal, SqlDecimal) 对两个 SqlDecimal 参数执行逻辑比较，以确定第一个参数是否小于或等于第二个参数。Performs a logical comparison of the two SqlDecimal parameters to determine whether the first is less than or equal to the second. Multiply(SqlDecimal, SqlDecimal) Multiply(SqlDecimal, SqlDecimal) Multiply(SqlDecimal, SqlDecimal) Multiply(SqlDecimal, SqlDecimal) 该乘法运算符计算两个 SqlDecimal 参数的乘积。The multiplication operator computes the product of the two SqlDecimal parameters. Subtraction(SqlDecimal, SqlDecimal) Subtraction(SqlDecimal, SqlDecimal) Subtraction(SqlDecimal, SqlDecimal) Subtraction(SqlDecimal, SqlDecimal) 计算从第一个 SqlDecimal 操作数中减去第二个操作数所得的结果。Calculates the results of subtracting the second SqlDecimal operand from the first. UnaryNegation(SqlDecimal) UnaryNegation(SqlDecimal) UnaryNegation(SqlDecimal) UnaryNegation(SqlDecimal) 一元负运算符对 SqlDecimal 参数求反。The unary minus operator negates the SqlDecimal parameter.