Decimal.MinusOne Champ
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.
Représente le nombre 1 négatif (-1).
public: static initonly System::Decimal MinusOne;
public static readonly decimal MinusOne;
staticval mutable MinusOne : decimal
Public Shared ReadOnly MinusOne As Decimal
L’exemple de code suivant illustre l’utilisation du MinusOne
champ.
// Example of the Decimal fields.
using namespace System;
int main()
{
String^ numberFmt = "{0,-25}{1,45:N0}";
String^ exprFmt = "{0,-55}{1,15}";
Console::WriteLine( "This example of the fields of the Decimal structure "
"\ngenerates the following output.\n" );
Console::WriteLine( numberFmt, "Field or Expression", "Value" );
Console::WriteLine( numberFmt, "-------------------", "-----" );
// Display the values of the Decimal fields.
Console::WriteLine( numberFmt, "Decimal::MaxValue", Decimal::MaxValue );
Console::WriteLine( numberFmt, "Decimal::MinValue", Decimal::MinValue );
Console::WriteLine( numberFmt, "Decimal::MinusOne", Decimal::MinusOne );
Console::WriteLine( numberFmt, "Decimal::One", Decimal::One );
Console::WriteLine( numberFmt, "Decimal::Zero", Decimal::Zero );
Console::WriteLine();
// Display the values of expressions of the Decimal fields.
Console::WriteLine( exprFmt, "( Decimal::MinusOne + Decimal::One ) == Decimal::Zero", (Decimal::MinusOne + Decimal::One) == Decimal::Zero );
Console::WriteLine( exprFmt, "Decimal::MaxValue + Decimal::MinValue", Decimal::MaxValue + Decimal::MinValue );
Console::WriteLine( exprFmt, "Decimal::MinValue / Decimal::MaxValue", Decimal::MinValue / Decimal::MaxValue );
Console::WriteLine( "{0,-40}{1,30}", "100000000000000M / Decimal::MaxValue", Convert::ToDecimal( 100000000000000 ) / Decimal::MaxValue );
}
/*
This example of the fields of the Decimal structure
generates the following output.
Field or Expression Value
------------------- -----
Decimal::MaxValue 79,228,162,514,264,337,593,543,950,335
Decimal::MinValue -79,228,162,514,264,337,593,543,950,335
Decimal::MinusOne -1
Decimal::One 1
Decimal::Zero 0
( Decimal::MinusOne + Decimal::One ) == Decimal::Zero True
Decimal::MaxValue + Decimal::MinValue 0
Decimal::MinValue / Decimal::MaxValue -1
100000000000000M / Decimal::MaxValue 0.0000000000000012621774483536
*/
// Example of the Decimal fields.
using System;
class DecimalFieldsDemo
{
public static void Main( )
{
const string numberFmt = "{0,-25}{1,45:N0}";
const string exprFmt = "{0,-55}{1,15}";
Console.WriteLine(
"This example of the fields of the Decimal structure " +
"\ngenerates the following output.\n" );
Console.WriteLine( numberFmt, "Field or Expression", "Value" );
Console.WriteLine( numberFmt, "-------------------", "-----" );
// Display the values of the Decimal fields.
Console.WriteLine( numberFmt, "Decimal.MaxValue",
Decimal.MaxValue );
Console.WriteLine( numberFmt, "Decimal.MinValue",
Decimal.MinValue );
Console.WriteLine( numberFmt, "Decimal.MinusOne",
Decimal.MinusOne );
Console.WriteLine( numberFmt, "Decimal.One", Decimal.One );
Console.WriteLine( numberFmt, "Decimal.Zero", Decimal.Zero );
Console.WriteLine( );
// Display the values of expressions of the Decimal fields.
Console.WriteLine( exprFmt,
"( Decimal.MinusOne + Decimal.One ) == Decimal.Zero",
(Decimal.MinusOne + Decimal.One ) == Decimal.Zero );
Console.WriteLine( exprFmt,
"Decimal.MaxValue + Decimal.MinValue",
Decimal.MaxValue + Decimal.MinValue );
Console.WriteLine( exprFmt,
"Decimal.MinValue / Decimal.MaxValue",
Decimal.MinValue / Decimal.MaxValue );
Console.WriteLine( "{0,-40}{1,30}",
"100000000000000M / Decimal.MaxValue",
100000000000000M / Decimal.MaxValue );
}
}
/*
This example of the fields of the Decimal structure
generates the following output.
Field or Expression Value
------------------- -----
Decimal.MaxValue 79,228,162,514,264,337,593,543,950,335
Decimal.MinValue -79,228,162,514,264,337,593,543,950,335
Decimal.MinusOne -1
Decimal.One 1
Decimal.Zero 0
( Decimal.MinusOne + Decimal.One ) == Decimal.Zero True
Decimal.MaxValue + Decimal.MinValue 0
Decimal.MinValue / Decimal.MaxValue -1
100000000000000M / Decimal.MaxValue 0.0000000000000012621774483536
*/
// Example of the Decimal fields.
open System
let numberFmt obj1 obj2 = printfn $"{obj1,-25}{obj2,45:N0}"
let exprFmt obj1 obj2 = printfn $"{obj1,-55}{obj2,15}"
printfn "This example of the fields of the Decimal structure \ngenerates the following output.\n"
numberFmt "Field or Expression" "Value"
numberFmt "-------------------" "-----"
// Display the values of the Decimal fields.
numberFmt "Decimal.MaxValue" Decimal.MaxValue
numberFmt "Decimal.MinValue" Decimal.MinValue
numberFmt "Decimal.MinusOne" Decimal.MinusOne
numberFmt "Decimal.One" Decimal.One
numberFmt "Decimal.Zero" Decimal.Zero
printfn ""
// Display the values of expressions of the Decimal fields.
exprFmt "( Decimal.MinusOne + Decimal.One ) == Decimal.Zero" (Decimal.MinusOne + Decimal.One = Decimal.Zero)
exprFmt "Decimal.MaxValue + Decimal.MinValue" (Decimal.MaxValue + Decimal.MinValue)
exprFmt "Decimal.MinValue / Decimal.MaxValue" (Decimal.MinValue / Decimal.MaxValue)
printfn "%-40s%30O" "100000000000000M / Decimal.MaxValue" (100000000000000M / Decimal.MaxValue)
// This example of the fields of the Decimal structure
// generates the following output.
//
// Field or Expression Value
// ------------------- -----
// Decimal.MaxValue 79,228,162,514,264,337,593,543,950,335
// Decimal.MinValue -79,228,162,514,264,337,593,543,950,335
// Decimal.MinusOne -1
// Decimal.One 1
// Decimal.Zero 0
//
// ( Decimal.MinusOne + Decimal.One ) == Decimal.Zero True
// Decimal.MaxValue + Decimal.MinValue 0
// Decimal.MinValue / Decimal.MaxValue -1
// 100000000000000M / Decimal.MaxValue 0.0000000000000012621774483536
' Example of the Decimal fields.
Module DecimalFieldsDemo
Sub Main( )
Const numberFmt As String = "{0,-25}{1,45:N0}"
Const exprFmt As String = "{0,-55}{1,15}"
Console.WriteLine( _
"This example of the fields of the Decimal structure" & _
vbCrLf & "generates the following output." & vbCrLf )
Console.WriteLine( numberFmt, "Field or Expression", "Value" )
Console.WriteLine( numberFmt, "-------------------", "-----" )
' Display the values of the Decimal fields.
Console.WriteLine( numberFmt, "Decimal.MaxValue", _
Decimal.MaxValue )
Console.WriteLine( numberFmt, "Decimal.MinValue", _
Decimal.MinValue )
Console.WriteLine( numberFmt, "Decimal.MinusOne", _
Decimal.MinusOne )
Console.WriteLine( numberFmt, "Decimal.One", _
Decimal.One )
Console.WriteLine( numberFmt, "Decimal.Zero", _
Decimal.Zero )
Console.WriteLine( )
' Display the values of expressions of the Decimal fields.
Console.WriteLine( exprFmt, _
"( Decimal.MinusOne + Decimal.One ) = Decimal.Zero", _
( Decimal.MinusOne + Decimal.One ) = Decimal.Zero )
Console.WriteLine( exprFmt, _
"Decimal.MaxValue + Decimal.MinValue", _
Decimal.MaxValue + Decimal.MinValue )
Console.WriteLine( exprFmt, _
"Decimal.MinValue / Decimal.MaxValue", _
Decimal.MinValue/Decimal.MaxValue )
Console.WriteLine( "{0,-40}{1,30}", _
"100000000000000D / Decimal.MaxValue", _
100000000000000D / Decimal.MaxValue )
End Sub
End Module
' This example of the fields of the Decimal structure
' generates the following output.
'
' Field or Expression Value
' ------------------- -----
' Decimal.MaxValue 79,228,162,514,264,337,593,543,950,335
' Decimal.MinValue -79,228,162,514,264,337,593,543,950,335
' Decimal.MinusOne -1
' Decimal.One 1
' Decimal.Zero 0
'
' ( Decimal.MinusOne + Decimal.One ) = Decimal.Zero True
' Decimal.MaxValue + Decimal.MinValue 0
' Decimal.MinValue / Decimal.MaxValue -1
' 100000000000000D / Decimal.MaxValue 0.0000000000000012621774483536
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 |
.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 :