Int16.MinValue 필드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
가능한 가장 작은 값을 Int16나타냅니다. 이 필드는 상수입니다.
public: short MinValue = -32768;
public const short MinValue = -32768;
val mutable MinValue : int16
Public Const MinValue As Short = -32768
필드 값
Value = -32768예제
다음 예제에서는 값을 변환할 때 방지 OverflowException 하려면 Int16 속성을 사용 합니다MinValue.
long[] numbersToConvert = {162345, 32183, -54000};
short newNumber;
foreach (long number in numbersToConvert)
{
if (number >= Int16.MinValue && number <= Int16.MaxValue)
{
newNumber = Convert.ToInt16(number);
Console.WriteLine($"Successfully converted {newNumber} to an Int16.");
}
else
{
Console.WriteLine($"Unable to convert {number} to an Int16.");
}
}
// The example displays the following output to the console:
// Unable to convert 162345 to an Int16.
// Successfully converted 32183 to an Int16.
// Unable to convert -54000 to an Int16.
open System
let numbersToConvert = [ 162345L; 32183L; -54000L ]
for number in numbersToConvert do
if number >= int64 Int16.MinValue && number <= int64 Int16.MaxValue then
let newNumber = Convert.ToInt16 number
printfn $"Successfully converted {newNumber} to an Int16."
else
printfn $"Unable to convert {number} to an Int16."
// The example displays the following output to the console:
// Unable to convert 162345 to an Int16.
// Successfully converted 32183 to an Int16.
// Unable to convert -54000 to an Int16.
Dim numbersToConvert() As Long = {162345, 32183, -54000}
Dim newNumber As Int16
For Each number As Long In NumbersToConvert
If number >= Int16.MinValue And number <= Int16.MaxValue Then
newNumber = Convert.ToInt16(number)
Console.WriteLine("Successfully converted {0} to an Int16.", _
newNumber)
Else
Console.WriteLine("Unable to convert {0} to an Int16.", number)
End If
Next
' The example displays the following output to the console:
' Unable to convert 162345 to an Int16.
' Successfully converted 32183 to an Int16.
' Unable to convert -54000 to an Int16.
설명
이 상수의 값은 -32768입니다. 즉, 16진수 0x8000.
이 MinValue 속성은 일반적으로 더 낮은 범위(예: a 또는 a)를 가진 숫자 형식에서 숫자 형식으로 Int32 변환하는 경우를 Int64방지하는 OverflowException 데 Int16사용됩니다. 이 예제에서는 이 사용량을 보여 줍니다.