Decimal.MaxValue 欄位

定義

代表 Decimal 最大的可能值。 這個欄位是不變且唯讀的。

public: static initonly System::Decimal MaxValue;
public static readonly decimal MaxValue;
 staticval mutable MaxValue : decimal
Public Shared ReadOnly MaxValue As Decimal 

欄位值

Decimal

範例

下列程式碼範例說明如何使用 MaxValue

   public ref class PiggyBank
   {
   public:
      Decimal Capacity()
      {
         return MyFortune.MaxValue;
      }

      void AddPenny()
      {
         MyFortune = Decimal::Add(MyFortune, (Decimal).01);
      }

   protected:
      Decimal MyFortune;
   };

}
class PiggyBank {
    public decimal Capacity {
        get {
            return Decimal.MaxValue;
        }
    }

    protected decimal MyFortune;

    public void AddPenny() {
        MyFortune += .01m;
    }
}
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

備註

這個常數的值是正79228162514264337593543950335。

適用於

另請參閱