# 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.