Decimal.Add(Decimal, Decimal) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Adiciona dois valores especificados Decimal .
public:
static System::Decimal Add(System::Decimal d1, System::Decimal d2);
public static decimal Add(decimal d1, decimal d2);
static member Add : decimal * decimal -> decimal
Public Shared Function Add (d1 As Decimal, d2 As Decimal) As Decimal
Parâmetros
- d1
- Decimal
O primeiro valor a acrescentar.
- d2
- Decimal
O segundo valor a acrescentar.
Devoluções
A soma de d1 e d2.
Exceções
A soma de d1 e d2 é menor que Valor Mínimo Decimal ou maior que Valor MáximoDecimal.
Observações
O exemplo de código seguinte ilustra a utilização de Add :
class PiggyBank {
public void AddPenny() {
MyFortune = Decimal.Add(MyFortune, .01m);
}
public override string ToString() {
return MyFortune.ToString("C")+" in piggy bank";
}
protected decimal MyFortune;
}
type PiggyBank() =
let mutable myFortune = 0m
member _.AddPenny() =
myFortune <- Decimal.Add(myFortune, 0.01m)
override _.ToString() =
$"{myFortune:C} in piggy bank"
Class PiggyBank
Public Sub AddPenny()
MyFortune = [Decimal].Add(MyFortune, 0.01D)
End Sub
Public Overrides Function ToString() As String
Return MyFortune.ToString("C") + " in piggy bank"
End Function
Protected MyFortune As Decimal
End Class