Decimal.Add(Decimal, Decimal) Méthode
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Ajoute deux valeurs Decimal spécifiées.
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
- d1
- Decimal
Première valeur à ajouter.
- d2
- Decimal
Seconde valeur à ajouter.
Somme de d1
et d2
.
La somme de d1
et d2
est inférieure à Decimal.MinValue ou supérieure à Decimal.MaxValue.
L’exemple de code suivant illustre l’utilisation de Add
:
public ref class PiggyBank
{
public:
void AddPenny()
{
MyFortune = Decimal::Add( MyFortune, (Decimal).01 );
}
virtual System::String^ ToString() override
{
return MyFortune.ToString("C")+" in piggy bank";
}
protected:
Decimal MyFortune;
};
}
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
Produit | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
Commentaires sur .NET
.NET est un projet open source. Sélectionnez un lien pour fournir des commentaires: