Table of Contents

Struct short

Namespace
System
Assembly
mscorlib.dll

Represents a 16-bit signed integer.

public short
Inherited Members

Fields

MaxValue

Represents the largest possible value of an Int16. This field is constant.

public const short MaxValue = 32767

Field Value

short

Remarks

The value of this constant is 32767; that is, hexadecimal 0x7FFF.

MinValue

Represents the smallest possible value of Int16. This field is constant.

public const short MinValue = -32768

Field Value

short

Remarks

The value of this constant is -32768; that is, hexadecimal 0x8000.

Methods

Parse(string)

Converts the string representation of a number to its 16-bit signed integer equivalent.

public static short Parse(string s)

Parameters

s string

A string containing a number to convert.

Returns

short

A 16-bit signed integer equivalent to the number contained in s.

Exceptions

ArgumentNullException

s is null.

ToString()

Converts the numeric value of this instance to its equivalent string representation.

public override string ToString()

Returns

string

The string representation of the value of this instance, consisting of a minus sign if the value is negative, and a sequence of digits ranging from 0 to 9 with no leading zeroes.

ToString(string)

Converts the numeric value of this instance to its equivalent string representation, using the specified format

public string ToString(string format)

Parameters

format string

A numeric format string.

Returns

string

The string representation of the value of this instance as specified by format.

TryParse(string, out short)

Converts the string representation of a number to its 16-bit signed integer equivalent. A return value indicates whether the conversion succeeded or failed.

public static bool TryParse(string s, out short result)

Parameters

s string

A string that contains a number to convert.

result short

When this method returns, contains the 16-bit signed integer value equivalent to the number contained in s, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null or Empty, is not of the correct format, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.

Returns

bool

true if s was converted successfully; otherwise, false.

Remarks

The TryParse(string, out short) method differs from the Parse(string) method by returning a bool value that indicates whether the parse operation succeeded instead of returning the parsed short value. It eliminates the need to use exception handling to test for a FormatException in the event that s is invalid and cannot be successfully parsed.