System.Decimal Structure
Namespace: System
The Decimal structure represents a 128-bit data type suitable for financial and monetary calculations where precision is critical. It provides 28-29 significant digits.
Syntax
public struct Decimal : IComparable, IComparable<Decimal>, IConvertible, IEquatable<Decimal>, IFormattable
Properties
| Name | Type | Description |
|---|---|---|
| Zero | Decimal | Constant representing the value 0. |
| One | Decimal | Constant representing the value 1. |
| MinValue | Decimal | Smallest possible value. |
| MaxValue | Decimal | Largest possible value. |
Methods
| Name | Signature | Description |
|---|---|---|
| Add | static Decimal Add(Decimal d1, Decimal d2) | Returns the sum of two decimals. |
| Subtract | static Decimal Subtract(Decimal d1, Decimal d2) | Returns the difference of two decimals. |
| Multiply | static Decimal Multiply(Decimal d1, Decimal d2) | Returns the product of two decimals. |
| Divide | static Decimal Divide(Decimal d1, Decimal d2) | Returns the quotient of two decimals. |
| Parse | static Decimal Parse(string s) | Converts a string representation of a number to a decimal. |
| TryParse | static bool TryParse(string s, out Decimal result) | Tries to convert a string to a decimal. |
| ToString | string ToString(string format, IFormatProvider provider) | Formats the value using specified format and culture. |