Export (0) Print
Expand All

Decimal.MaxValue Field

Represents the largest possible value of Decimal. This field is constant and read-only.

[Visual Basic]
Public Shared ReadOnly MaxValue As Decimal
[C#]
public static readonly decimal MaxValue;
[C++]
public: static Decimal MaxValue;
[JScript]
public static var MaxValue : Decimal;

Remarks

The value of this constant is positive 79,228,162,514,264,337,593,543,950,335.

Example

The following code sample illustrates the use of MaxValue:

[Visual Basic] 
Class PiggyBank
    Public ReadOnly Property Capacity() As Decimal
        Get
            Return [Decimal].MaxValue
        End Get
    End Property

    Protected MyFortune As Decimal

    Public Sub AddPenny()
        MyFortune += 0.01D
    End Sub
End Class

[C#] 
class PiggyBank {
    public decimal Capacity {
        get {
            return Decimal.MaxValue;
        }
    }

    protected decimal MyFortune;

    public void AddPenny() {
        MyFortune += .01m;
    }
}

[C++] 
public __gc class PiggyBank {
public: 
    Decimal Capacity() {
        return MyFortune.MaxValue;
    }

    void AddPenny() {
        Decimal::op_Addition(MyFortune, .01);
    }
protected:
    Decimal MyFortune;
};

[JScript] 
class PiggyBank {
    public function get Capacity() : Decimal {
            return Decimal.MaxValue;
    }

    protected var MyFortune : Decimal;

    public function AddPenny() {
        MyFortune = Decimal.Add(MyFortune, 0.01);
    }
}

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Decimal Structure | Decimal Members | System Namespace | Zero | One | MinusOne | MinValue

Show:
© 2014 Microsoft