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

注解

此常量的值为正 79,228,162,514,264,337,593,543,950,335。

适用于

另请参阅