Int16.MaxValue Field
.NET Framework (current version)
Represents the largest possible value of an Int16. This field is constant.
Assembly: mscorlib (in mscorlib.dll)
The value of this constant is 32767; that is, hexadecimal 0x7FFF.
The MaxValue property is typically used to prevent an OverflowException when converting from a numeric type with a greater upper range (such as a UInt16 or a Int32) to an Int16. The example illustrates this usage.
The following example uses the MaxValue property to prevent an OverflowException when converting to an Int16 value.
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.
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: