Math.Min Metodo

Definizione

Restituisce il meno elevato tra due numeri.Returns the smaller of two numbers.

Overload

Min(UInt64, UInt64)

Restituisce il meno elevato tra due interi senza segno a 64 bit.Returns the smaller of two 64-bit unsigned integers.

Min(UInt32, UInt32)

Restituisce il meno elevato tra due interi senza segno a 32 bit.Returns the smaller of two 32-bit unsigned integers.

Min(UInt16, UInt16)

Restituisce il meno elevato tra due interi senza segno a 16 bit.Returns the smaller of two 16-bit unsigned integers.

Min(Single, Single)

Restituisce il meno elevato tra due numeri a virgola mobile e precisione singola.Returns the smaller of two single-precision floating-point numbers.

Min(SByte, SByte)

Restituisce il meno elevato tra due interi con segno a 8 bit.Returns the smaller of two 8-bit signed integers.

Min(Int64, Int64)

Restituisce il meno elevato tra due interi con segno a 64 bit.Returns the smaller of two 64-bit signed integers.

Min(Int32, Int32)

Restituisce il meno elevato tra due interi con segno a 32 bit.Returns the smaller of two 32-bit signed integers.

Min(Int16, Int16)

Restituisce il meno elevato tra due interi con segno a 16 bit.Returns the smaller of two 16-bit signed integers.

Min(Double, Double)

Restituisce il meno elevato tra due numeri a virgola mobile e precisione doppia.Returns the smaller of two double-precision floating-point numbers.

Min(Decimal, Decimal)

Restituisce il meno elevato tra due numeri decimali.Returns the smaller of two decimal numbers.

Min(Byte, Byte)

Restituisce il meno elevato tra due interi senza segno a 8 bit.Returns the smaller of two 8-bit unsigned integers.

Min(UInt64, UInt64)

Importante

Questa API non è conforme a CLS.

Restituisce il meno elevato tra due interi senza segno a 64 bit.Returns the smaller of two 64-bit unsigned integers.

public:
 static System::UInt64 Min(System::UInt64 val1, System::UInt64 val2);
[System.CLSCompliant(false)]
public static ulong Min (ulong val1, ulong val2);
static member Min : uint64 * uint64 -> uint64
Public Shared Function Min (val1 As ULong, val2 As ULong) As ULong

Parametri

val1
UInt64

Primo di due interi senza segno a 64 bit da confrontare.The first of two 64-bit unsigned integers to compare.

val2
UInt64

Secondo di due interi senza segno a 64 bit da confrontare.The second of two 64-bit unsigned integers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Attributi

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(UInt32, UInt32)

Importante

Questa API non è conforme a CLS.

Restituisce il meno elevato tra due interi senza segno a 32 bit.Returns the smaller of two 32-bit unsigned integers.

public:
 static System::UInt32 Min(System::UInt32 val1, System::UInt32 val2);
[System.CLSCompliant(false)]
public static uint Min (uint val1, uint val2);
static member Min : uint32 * uint32 -> uint32
Public Shared Function Min (val1 As UInteger, val2 As UInteger) As UInteger

Parametri

val1
UInt32

Primo di due interi senza segno a 32 bit da confrontare.The first of two 32-bit unsigned integers to compare.

val2
UInt32

Secondo di due interi senza segno a 32 bit da confrontare.The second of two 32-bit unsigned integers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Attributi

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(UInt16, UInt16)

Importante

Questa API non è conforme a CLS.

Restituisce il meno elevato tra due interi senza segno a 16 bit.Returns the smaller of two 16-bit unsigned integers.

public:
 static System::UInt16 Min(System::UInt16 val1, System::UInt16 val2);
[System.CLSCompliant(false)]
public static ushort Min (ushort val1, ushort val2);
static member Min : uint16 * uint16 -> uint16
Public Shared Function Min (val1 As UShort, val2 As UShort) As UShort

Parametri

val1
UInt16

Primo di due interi senza segno a 16 bit da confrontare.The first of two 16-bit unsigned integers to compare.

val2
UInt16

Secondo di due interi senza segno a 16 bit da confrontare.The second of two 16-bit unsigned integers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Attributi

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(Single, Single)

Restituisce il meno elevato tra due numeri a virgola mobile e precisione singola.Returns the smaller of two single-precision floating-point numbers.

public:
 static float Min(float val1, float val2);
public static float Min (float val1, float val2);
static member Min : single * single -> single
Public Shared Function Min (val1 As Single, val2 As Single) As Single

Parametri

val1
Single

Primo di due numeri a virgola mobile e precisione singola da confrontare.The first of two single-precision floating-point numbers to compare.

val2
Single

Secondo di due numeri a virgola mobile e precisione singola da confrontare.The second of two single-precision floating-point numbers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller. Se val1, val2 o sia val1 che val2 sono uguali a NaN, verrà restituito NaN.If val1, val2, or both val1 and val2 are equal to NaN, NaN is returned.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(SByte, SByte)

Importante

Questa API non è conforme a CLS.

Restituisce il meno elevato tra due interi con segno a 8 bit.Returns the smaller of two 8-bit signed integers.

public:
 static System::SByte Min(System::SByte val1, System::SByte val2);
[System.CLSCompliant(false)]
public static sbyte Min (sbyte val1, sbyte val2);
static member Min : sbyte * sbyte -> sbyte
Public Shared Function Min (val1 As SByte, val2 As SByte) As SByte

Parametri

val1
SByte

Primo di due interi con segno a 8 bit da confrontare.The first of two 8-bit signed integers to compare.

val2
SByte

Secondo di due interi con segno a 8 bit da confrontare.The second of two 8-bit signed integers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Attributi

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(Int64, Int64)

Restituisce il meno elevato tra due interi con segno a 64 bit.Returns the smaller of two 64-bit signed integers.

public:
 static long Min(long val1, long val2);
public static long Min (long val1, long val2);
static member Min : int64 * int64 -> int64
Public Shared Function Min (val1 As Long, val2 As Long) As Long

Parametri

val1
Int64

Primo di due interi con segno a 64 bit da confrontare.The first of two 64-bit signed integers to compare.

val2
Int64

Secondo di due interi con segno a 64 bit da confrontare.The second of two 64-bit signed integers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(Int32, Int32)

Restituisce il meno elevato tra due interi con segno a 32 bit.Returns the smaller of two 32-bit signed integers.

public:
 static int Min(int val1, int val2);
public static int Min (int val1, int val2);
static member Min : int * int -> int
Public Shared Function Min (val1 As Integer, val2 As Integer) As Integer

Parametri

val1
Int32

Primo di due interi con segno a 32 bit da confrontare.The first of two 32-bit signed integers to compare.

val2
Int32

Secondo di due interi con segno a 32 bit da confrontare.The second of two 32-bit signed integers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(Int16, Int16)

Restituisce il meno elevato tra due interi con segno a 16 bit.Returns the smaller of two 16-bit signed integers.

public:
 static short Min(short val1, short val2);
public static short Min (short val1, short val2);
static member Min : int16 * int16 -> int16
Public Shared Function Min (val1 As Short, val2 As Short) As Short

Parametri

val1
Int16

Primo di due interi con segno a 16 bit da confrontare.The first of two 16-bit signed integers to compare.

val2
Int16

Secondo di due interi con segno a 16 bit da confrontare.The second of two 16-bit signed integers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(Double, Double)

Restituisce il meno elevato tra due numeri a virgola mobile e precisione doppia.Returns the smaller of two double-precision floating-point numbers.

public:
 static double Min(double val1, double val2);
public static double Min (double val1, double val2);
static member Min : double * double -> double
Public Shared Function Min (val1 As Double, val2 As Double) As Double

Parametri

val1
Double

Primo di due numeri a virgola mobile e precisione doppia da confrontare.The first of two double-precision floating-point numbers to compare.

val2
Double

Secondo di due numeri a virgola mobile e precisione doppia da confrontare.The second of two double-precision floating-point numbers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller. Se val1, val2 o sia val1 che val2 sono uguali a NaN, verrà restituito NaN.If val1, val2, or both val1 and val2 are equal to NaN, NaN is returned.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(Decimal, Decimal)

Restituisce il meno elevato tra due numeri decimali.Returns the smaller of two decimal numbers.

public:
 static System::Decimal Min(System::Decimal val1, System::Decimal val2);
public static decimal Min (decimal val1, decimal val2);
static member Min : decimal * decimal -> decimal
Public Shared Function Min (val1 As Decimal, val2 As Decimal) As Decimal

Parametri

val1
Decimal

Primo di due numeri decimali da confrontare.The first of two decimal numbers to compare.

val2
Decimal

Secondo di due numeri decimali da confrontare.The second of two decimal numbers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Min(Byte, Byte)

Restituisce il meno elevato tra due interi senza segno a 8 bit.Returns the smaller of two 8-bit unsigned integers.

public:
 static System::Byte Min(System::Byte val1, System::Byte val2);
public static byte Min (byte val1, byte val2);
static member Min : byte * byte -> byte
Public Shared Function Min (val1 As Byte, val2 As Byte) As Byte

Parametri

val1
Byte

Primo di due interi senza segno a 8 bit da confrontare.The first of two 8-bit unsigned integers to compare.

val2
Byte

Secondo di due interi senza segno a 8 bit da confrontare.The second of two 8-bit unsigned integers to compare.

Restituisce

Parametro val1 o val2, qualunque sia il minore.Parameter val1 or val2, whichever is smaller.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il Min metodo per restituire e visualizzare il minore di due variabili.The following example demonstrates how to use the Min method to return and display the smaller of two variables.

// This example demonstrates Math.Min()
using namespace System;
int main()
{
   String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}.";
   String^ nl = Environment::NewLine;
   Byte xByte1 = 1,xByte2 = 51;
   short xShort1 = -2,xShort2 = 52;
   int xInt1 = -3,xInt2 = 53;
   long xLong1 = -4,xLong2 = 54;
   float xSingle1 = 5.0f,xSingle2 = 55.0f;
   double xDouble1 = 6.0,xDouble2 = 56.0;
   Decimal xDecimal1 = 7,xDecimal2 = 57;
   
   // The following types are not CLS-compliant.
   SByte xSbyte1 = 101,xSbyte2 = 111;
   UInt16 xUshort1 = 102,xUshort2 = 112;
   UInt32 xUint1 = 103,xUint2 = 113;
   UInt64 xUlong1 = 104,xUlong2 = 114;
   Console::WriteLine( "{0}Display the lesser of two values:{0}", nl );
   Console::WriteLine( str, "Byte   ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) );
   Console::WriteLine( str, "Int16  ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) );
   Console::WriteLine( str, "Int32  ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) );
   Console::WriteLine( str, "Int64  ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) );
   Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) );
   Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) );
   Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) );
   
   //
   Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl );
   Console::WriteLine( str, "SByte  ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) );
   Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) );
   Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) );
   Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) );
}

/*
This example produces the following results:

Display the lesser of two values:

Byte   : The lesser of   1 and  51 is 1.
Int16  : The lesser of  -2 and  52 is -2.
Int32  : The lesser of  -3 and  53 is -3.
Int64  : The lesser of  -4 and  54 is -4.
Single : The lesser of   5 and  55 is 5.
Double : The lesser of   6 and  56 is 6.
Decimal: The lesser of   7 and  57 is 7.

The following types are not CLS-compliant:

SByte  : The lesser of 101 and 111 is 101.
UInt16 : The lesser of 102 and 112 is 102.
UInt32 : The lesser of 103 and 113 is 103.
UInt64 : The lesser of 104 and 114 is 104.
*/
   string str = "{0}: The lesser of {1,3} and {2,3} is {3}.";

   byte     xByte1    = 1,    xByte2    = 51;	
   short    xShort1   = -2,   xShort2   = 52;
   int      xInt1     = -3,   xInt2     = 53;
   long     xLong1    = -4,   xLong2    = 54;
   float    xSingle1  = 5.0f, xSingle2  = 55.0f;
   double   xDouble1  = 6.0,  xDouble2  = 56.0;
   Decimal  xDecimal1 = 7m,   xDecimal2 = 57m;

   // The following types are not CLS-compliant.
   sbyte    xSbyte1   = 101, xSbyte2  = 111;
   ushort   xUshort1  = 102, xUshort2 = 112;
   uint     xUint1    = 103, xUint2   = 113;
   ulong    xUlong1   = 104, xUlong2  = 114;

   Console.WriteLine("Display the lesser of two values:\n");
   Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2));
   Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2));
   Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2));
   Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2));
   Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2));
   Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2));
   Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2));

   Console.WriteLine("\nThe following types are not CLS-compliant:\n");
   Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2));
   Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2));
   Console.WriteLine(str, "UInt32 ", xUint1, xUint2, Math.Min(xUint1, xUint2));
   Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2));

   /*
   This example produces the following results:

   Display the lesser of two values:

   Byte   : The lesser of   1 and  51 is 1.
   Int16  : The lesser of  -2 and  52 is -2.
   Int32  : The lesser of  -3 and  53 is -3.
   Int64  : The lesser of  -4 and  54 is -4.
   Single : The lesser of   5 and  55 is 5.
   Double : The lesser of   6 and  56 is 6.
   Decimal: The lesser of   7 and  57 is 7.

   The following types are not CLS-compliant:

   SByte  : The lesser of 101 and 111 is 101.
   UInt16 : The lesser of 102 and 112 is 102.
   UInt32 : The lesser of 103 and 113 is 103.
   UInt64 : The lesser of 104 and 114 is 104.
   */
' This example demonstrates Math.Min()
Class Sample
   Public Shared Sub Main()
      Dim str As String = "{0}: The lesser of {1,3} and {2,3} is {3}."
      Dim nl As String = Environment.NewLine
      
      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D
      
      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114
      
      Console.WriteLine("{0}Display the lesser of two values:{0}", nl)
      Console.WriteLine(str, "Byte   ", xByte1, xByte2, Math.Min(xByte1, xByte2))
      Console.WriteLine(str, "Int16  ", xShort1, xShort2, Math.Min(xShort1, xShort2))
      Console.WriteLine(str, "Int32  ", xInt1, xInt2, Math.Min(xInt1, xInt2))
      Console.WriteLine(str, "Int64  ", xLong1, xLong2, Math.Min(xLong1, xLong2))
      Console.WriteLine(str, "Single ", xSingle1, xSingle2, Math.Min(xSingle1, xSingle2))
      Console.WriteLine(str, "Double ", xDouble1, xDouble2, Math.Min(xDouble1, xDouble2))
      Console.WriteLine(str, "Decimal", xDecimal1, xDecimal2, Math.Min(xDecimal1, xDecimal2))
      '
      Console.WriteLine("{0}The following types are not CLS-compliant:{0}", nl)
      Console.WriteLine(str, "SByte  ", xSbyte1, xSbyte2, Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(str, "UInt16 ", xUshort1, xUshort2, Math.Min(xUshort1, xUshort2))
      Console.WriteLine(str, "UInt32 ", xUint1, xUInt2, Math.Min(xUInt1, xUInt2))
      Console.WriteLine(str, "UInt64 ", xUlong1, xUlong2, Math.Min(xUlong1, xUlong2))
   End Sub
End Class
'
' This example produces the following results:
'
' Display the lesser of two values:
'
' Byte   : The lesser of   1 and  51 is 1.
' Int16  : The lesser of  -2 and  52 is -2.
' Int32  : The lesser of  -3 and  53 is -3.
' Int64  : The lesser of  -4 and  54 is -4.
' Single : The lesser of   5 and  55 is 5.
' Double : The lesser of   6 and  56 is 6.
' Decimal: The lesser of   7 and  57 is 7.
'
' The following types are not CLS-compliant:
' 
' SByte  : The lesser of 101 and 111 is 101.
' UInt16 : The lesser of 102 and 112 is 102.
' UInt32 : The lesser of 103 and 113 is 103.
' UInt64 : The lesser of 104 and 114 is 104.

Si applica a