The Methods and Fields Defined by Decimal : decimal « Data Type « C# / CSharp Tutorial






MethodMeaning
public static decimal Add(decimal v1,decimal v2)Returns v1 + v2.
public static int CompareTo(decimal v1,decimal v2)Returns zero if the values are equal. Returns a negative value if v1 is less than v2. Returns a positive value if v1 is greater than v2.
public int CompareTo(object v)Returns zero if the values are equal. Returns a negative value if the invoking object has a lower value. Returns a positive value if the invoking object has a greater value.
public static decimal Divide(decimal v1,decimal v2)Returns v1 / v2.
public override bool Equals(object v)Returns true if the value of the invoking object equals the value of v.
public static bool Equals(decimal v1,decimal v2)Returns true if v1 equals v2.
public static decimal Floor(decimal v)Returns the largest integer (represented as a decimal value) not greater than v. For example, given 1.02, Floor() returns 1.0. Given -1.02, Floor() returns -2.
public static decimalFromOACurrency(long v)Converts the OLE Automation value in v into its decimal equivalent and returns the result.
public static int[ ] GetBits(decimal v)Returns the binary representation of v and returns it in an array of ints. The organization of this array is as described in the text.
public override int GetHashCode()Returns the hash code for the invoking object.
public TypeCode GetTypeCode()Returns the TypeCode enumeration value for Decimal, which is TypeCode.Decimal.
public static decimal Multiply(decimal v1,decimal v2)Returns v1 * v2.
public static decimal Negate(decimal v)Returns -v.
public static decimal Parse(string str)Returns the binary equivalent of the numeric string in str.
public static decimalParse(string str,IFormatProvider fmtpvdr)Returns the binary equivalent of the numeric string in str using the culture-specific information provided by fmtpvdr.
public static decimalParse(string str, NumberStyles styles)Returns the binary equivalent of the numeric string in str, using the style information provided by styles.
public static decimalParse(string str,NumberStyles styles,IFormatProvider fmtpvdr)Returns the binary equivalent of the numeric string in str using the style information provided by styles and the culture-specific format information provided by fmtpvdr.
public static decimalRemainder(decimal v1, decimal v2)Returns the remainder of the integer division v1 / v2.
public static decimalRound(decimal v, int decPlaces)Returns the value of v rounded to the number of decimal places specified by decPlaces, which must be between 0 and 28.
public static decimalSubtract(decimal v1, decimal v2)Returns v1 - v2.
public static byte ToByte(decimal v)Returns the byte equivalent of v. Any fractional component is truncated. An OverflowException occurs if v is not within the range of a byte.
public static double ToDouble(decimal v)Returns the double equivalent of v. A loss of precision may occur because double has fewer significant digits than does decimal.
public static short ToInt16(decimal v)Returns the short equivalent of v. Any fractional component is truncated. An OverflowException occurs if v is not within the range of a short.
public static int ToInt32(decimal v)Returns the int equivalent of v. Any fractional component is truncated. An OverflowException occurs if v is not within the range of an int.
public static long ToInt64(decimal v)Returns the long equivalent of v. Any fractional component is truncated. An OverflowException occurs if v is not within the range of a long.
public static longToOACurrency(decimal v)Converts v into the equivalent OLE Automation value and returns the result.
public static sbyte ToSByte(decimal v)Returns the sbyte equivalent of v. Any fractional component is truncated. An OverflowException occurs if v is not within the range of an sbyte.
public static float ToSingle(decimal v)Returns the float equivalent of v. A loss of precision may occur because float has fewer significant digits than does decimal.
public override string ToString()Returns the string representation of the value of the invoking object.
public string ToString(string format)Returns the string representation of the value of the invoking object as specified by the format string passed in format.
public stringToString(IFormatProvider fmtpvdr)Returns the string representation of the value of the invoking object using the culture-specific information specified in fmtpvdr.
public stringToString(string format,IFormatProvider fmtpvdr)Returns the string representation of the value of the invoking object using the culture-specific information specified in fmtpvdr and the format specified by format.
public static ushort ToUInt16(decimal v)Returns the ushort equivalent of v. Any fractional component is truncated. An OverflowException occurs if v is not within the range of a ushort.
public static uint ToUInt32(decimal v)Returns the uint equivalent of v. Any fractional component is truncated. An OverflowException occurs if v is not within the range of a uint.
public static ulong ToUInt64(decimal v)Returns the ulong equivalent of v. Any fractional component is truncated. An OverflowException occurs if v is not within the range of a ulong.
public static decimal Truncate(decimal v)Returns the whole-number portion of v. Thus, it truncates any fractional digits.


FieldMeaning
public static readonly decimal MaxValueThe largest value that a decimal can hold.
public static readonly decimal MinusOneThe decimal representation of -1.
public static readonly decimal MinValueThe smallest value that a decimal can hold.
public static readonly decimal OneThe decimal representation of 1.
public static readonly decimal ZeroThe decimal representation of 0.










2.30.decimal
2.30.1.Declare decimal variable
2.30.2.To specify a decimal constant, begin the specification with a nonzero digit.
2.30.3.Manually create a decimal number.
2.30.4.The Methods and Fields Defined by Decimal
2.30.5.decimal literal
2.30.6.decimals and arithmetic operators
2.30.7.Decimal ranges
2.30.8.Specifying a Literal decimal
2.30.9.decimal Types