BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 This type is safe for multithreaded operations. System.ValueType System.IComparable System.IComparable<System.Int16> System.IConvertible System.IEquatable<System.Int16> System.IFormattable System.Runtime.InteropServices.ComVisible(true)

The value type represents signed integers with values ranging from negative 32768 through positive 32767.

This type provides methods to convert the value of an instance of this type to its string representation, to convert the string representation of a number to an instance of this type, and to compare instances of this type.

You can also call the members of the class to perform a wide range of numeric operations, including getting the absolute value of a number, calculating the quotient and remainder from integral division, determining the maximum or minimum value of two integers, getting the sign of a number, and rounding a number.

For information about how format specification codes control the string representation of value types, see Formatting Types.

Represents a 16-bit signed integer.

- Method
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This method implements the interface and performs slightly better than the method because it does not have to convert the parameter to an object.

  Depending on your programming language, it might be possible to code a method where the parameter type has fewer bits (is narrower) than the instance type. This is possible because some programming languages perform an implicit widening conversion that represents the parameter as a type with as many bits as the instance.

  For example, suppose the instance type is and the parameter type is . The Microsoft C# compiler generates instructions to represent the value of the parameter as an object, then generates a method that compares the values of the instance and the parameter representation.

  Consult your programming language's documentation to determine whether its compiler performs implicit widening conversions on numeric types.

  Compares this instance to a specified 16-bit signed integer and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified 16-bit signed integer.

  A signed number indicating the relative values of this instance and .

  Return Value

  Description

  Less than zero

  This instance is less than .

  Zero

  This instance is equal to .

  Greater than zero

  This instance is greater than .

  An integer to compare.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 `` is not a and is not a null reference.

  An , regardless of its value, is considered greater than a null reference.

  The parameter must be null or an instance of ; otherwise, an exception is thrown.

  Compares this instance to a specified object and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the object.

  A signed number indicating the relative values of this instance and .

  Return Value

  Description

  Less than zero

  This instance is less than .

  Zero

  This instance is equal to .

  Greater than zero

  This instance is greater than .

  -or-

  is null.

  An object to compare, or null. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method implements the interface, and performs slightly better than because it does not have to convert the parameter to an object.

  Returns a value indicating whether this instance is equal to a specified value.

  true if has the same value as this instance; otherwise, false.

  An value to compare to this instance.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This method overrides .

  Returns a value indicating whether this instance is equal to a specified object.

  true if is an instance of and equals the value of this instance; otherwise, false.

  An object to compare to this instance. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32

  The algorithm used to generate the hash code is unspecified.

  This method overrides .

  Returns the hash code for this instance.

  A 32-bit signed integer hash code.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.TypeCode To be added.

  Returns the for value type .

  The enumerated constant, .

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 32767

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

  The property is typically used to prevent an when converting from a numeric type with a greater upper range (such as a or a ) to an . The example illustrates this usage.

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

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 -32768

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

  The property is typically used to prevent an when converting from a numeric type with a greater lower range (such as an or an ) to an . The example illustrates this usage.

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

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 `` is a null reference. is not in the correct style. represents a number greater than or less than .

  This example demonstrates parsing a string to a .

  `using System; public class Int16ParseClass { public static void Main() { string str = " 100 "; Console.WriteLine("String: \"{0}\" <Int16> {1}",str,Int16.Parse(str)); } }`

  The output is

  String: " 100 " <Int16> 100

  The parameter contains a number of the form:

  [ws][sign]digits[ws]

  Elements in square brackets ([ and ]) are optional. The following table describes each element.

  Element

  Description

  ws

  Optional white space.

  sign

  An optional sign.

  digits

  A sequence of digits ranging from 0 to 9.

  The parameter is interpreted using the style. In addition to the integer value's decimal digits, only leading and trailing spaces together with a leading sign are allowed. To explicitly define the style elements that can be present in , use either the or the method.

  The parameter is parsed using the formatting information in a object that is initialized for the current system culture. For more information, see . To parse a string using the formatting information of some other culture, use the or the method.

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

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

  A string containing a number to convert. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 `` `` is a null reference. is not in the correct style. represents a number greater than or less than . A string containing a number to convert. A bitwise combination of the enumeration values that indicates the style elements that can be present in . A typical value to specify is .

  The parameter defines the style elements (such as white space or a sign symbol) that are allowed in the parameter for the parse operation to succeed. It must be a combination of bit flags from the enumeration. Depending on the value of , the parameter may include the following elements:

  [ws][$][sign][digits,]digits[.fractional_digits][e[sign]digits][ws]

  Or, if includes :

  [ws]hexdigits[ws]

  Items in square brackets ([ and ]) are optional. The following table describes each element.

  Element

  Description

  ws

  Optional white space. White space can appear at the beginning of if includes the flag, or at the end of if includes the flag.

  $

  A culture-specific currency symbol. Its position in the string is defined by the and property of the current culture. The current culture's currency symbol can appear in if includes the flag.

  sign

  An optional sign. The sign can appear at the beginning of if includes the flag, and it can appear at the end of if includes the flag. Parentheses can be used in to indicate a negative value if includes the flag.

  digits

  A sequence of digits from 0 through 9.

  ,

  A culture-specific thousands separator symbol. The current culture's thousands separator symbol can appear in if includes the flag.

  .

  A culture-specific decimal point symbol. The current culture's decimal point symbol can appear in if includes the flag.

  fractional_digits

  A sequence of the 0 digit. Fractional digits can appear in if includes the flag. If any digit other than 0 appears in fractional_digits, the method throws an .

  e

  The 'e' or 'E' character, which indicates that can be represented in exponential notation. The parameter can represent a number in exponential notation if includes the flag. However, the parameter must represent a number in the range of the data type and cannot have a non-zero fractional component.

  hexdigits

  A sequence of hexadecimal digits from 0 through f, or 0 through F.

  A string with digits only (which corresponds to the style) always parses successfully. Most of the remaining members control elements that may be but are not required to be present in this input string. The following table indicates how individual members affect the elements that may be present in .

  Non-composite NumberStyles values

  Elements permitted in s in addition to digits

  Decimal digits only.

  The . and fractional_digits elements. However, fractional_digits must consist of only one or more 0 digits or an is thrown.

  The parameter can also use exponential notation.

  The ws element at the beginning of .

  The ws element at the end of .

  A sign can appear before digits.

  A sign can appear after digits.

  The sign element in the form of parentheses enclosing the numeric value.

  The , element.

  The $ element.

  If the flag is used, must be the string representation of a hexadecimal value. The only other flags that can be present in are and . (The enumeration has a composite number style, , that includes both white space flags.)

  The parameter is parsed using the formatting information in a object that is initialized for the current system culture. For more information, see . To parse using the formatting information of a specific culture, call the method.

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

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

  A string containing a number to convert. A bitwise combination of the enumeration values that indicates the style elements that can be present in . A typical value to specify is . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 `` `` is a null reference. is not in the correct style. represents a number greater than or less than . A string containing a number to convert.

  The parameter contains a number of the form:

  [ws][sign]digits[ws]

  Elements in square brackets ([ and ]) are optional. The following table describes each element.

  Element

  Description

  ws

  An optional white space.

  sign

  An optional sign.

  digits

  A sequence of digits ranging from 0 to 9.

  The parameter is interpreted using the style. In addition to decimal digits, only leading and trailing spaces together with a leading sign are allowed in . To explicitly define the style elements together with the culture-specific formatting information that can be present in , use the method.

  The parameter is an implementation that obtains a object. The provides culture-specific information about the format of . If is null, the for the current culture is used.

  Converts the string representation of a number in a specified culture-specific format to its 16-bit signed integer equivalent.

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

  A string containing a number to convert. An that supplies culture-specific formatting information about . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 `` `` `` is a null reference. is not in the correct style. represents a number greater than or less than . A string containing a number to convert. A bitwise combination of enumeration values that indicates the style elements that can be present in . A typical value to specify is .

  The parameter defines the style elements (such as white space or the positive sign) that are allowed in the parameter for the parse operation to succeed. It must be a combination of bit flags from the enumeration. Depending on the value of , the parameter may include the following elements:

  [ws][$][sign][digits,]digits[.fractional_digits][e[sign]digits][ws]

  Or, if includes :

  [ws]hexdigits[ws]

  Elements in square brackets ([ and ]) are optional. The following table describes each element.

  Element

  Description

  ws

  Optional white space. White space can appear at the beginning of if includes the flag, or at the end of if includes the flag.

  $

  A culture-specific currency symbol. Its position in the string is defined by the and property of the current culture. The current culture's currency symbol can appear in if includes the flag.

  sign

  An optional sign. The sign can appear at the beginning of if includes the flag, and it can appear at the end of if includes the flag. Parentheses can be used in to indicate a negative value if includes the flag.

  digits

  A sequence of digits from 0 through 9.

  ,

  A culture-specific thousands separator symbol. The current culture's thousands separator symbol can appear in if includes the flag.

  .

  A culture-specific decimal point symbol. The current culture's decimal point symbol can appear in if includes the flag.

  fractional_digits

  A sequence of the 0 digit. Fractional digits can appear in if includes the flag. If any digit other than 0 appears in fractional_digits, the method throws an .

  e

  The 'e' or 'E' character, which indicates that can be represented in exponential notation. The parameter can represent a number in exponential notation if includes the flag. However, the parameter must represent a number in the range of the data type and cannot have a non-zero fractional component.

  hexdigits

  A sequence of hexadecimal digits from 0 through f, or 0 through F.

  A string with digits only (which corresponds to the style) always parses successfully. Most of the remaining members control elements that may be but are not required to be present in this input string. The following table indicates how individual members affect the elements that may be present in .

  Non-composite NumberStyles values

  Elements permitted in s in addition to digits

  Decimal digits only.

  The . and fractional_digits elements. However, fractional_digits must consist of only one or more 0 digits or an is thrown.

  The parameter can also use exponential notation.

  The ws element at the beginning of .

  The ws element at the end of .

  A sign can appear before digits.

  A sign can appear after digits.

  The sign element in the form of parentheses enclosing the numeric value.

  The , element.

  The $ element.

  If the flag is used, must be the string representation of a hexadecimal value. The only other flags that can be present in are and . (The enumeration has a composite number style, , that includes both white space flags.)

  The parameter is an implementation whose method obtains a object. The object provides culture-specific information about the format of . If is null, the object for the current culture is used.

  Converts the string representation of a number in a specified style and culture-specific format to its 16-bit signed integer equivalent.

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

  A string containing a number to convert. A bitwise combination of enumeration values that indicates the style elements that can be present in . A typical value to specify is . An that supplies culture-specific formatting information about . 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  true if the value of the current instance is not zero; otherwise, false.

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Byte ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Char ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.DateTime `` To be added.

  This conversion is not supported. Attempting to use this method throws an .

  This conversion is not supported. No value is returned.

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Decimal ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Double ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int16 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  For a description of this member, see .

  The value of the current instance, unchanged.

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int32 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to an .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to an .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.SByte ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to an .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Single ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Object `` `` To be added.

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the static (Shared in Visual Basic) method.

  For a description of this member, see .

  The value of the current instance, converted to .

  An implementation that supplies information about the format of the returned value.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt16 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, unchanged.

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt32 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.UInt64 ``

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. The recommended alternative is to call the method.

  For a description of this member, see .

  The value of the current instance, converted to a .

  This parameter is ignored.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String

  The method formats an value in the default ("G", or general) format by using the object of the current culture. If you want to specify a different format or culture, use the other overloads of the method, as follows:

  To use format

  For culture

  Use the overload

  Default ("G") format

  A specific culture

  A specific format

  Default (current) culture

  A specific format

  A specific culture

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  For more information about formatting, see Formatting Types.

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

  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.

  0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String ``

  The method formats an value in the default ("G", or general) format by using the object of a specified culture. If you want to specify a different format or the current culture, use the other overloads of the method, as follows:

  To use format

  For culture

  Use the overload

  Default ("G") format

  Default (current) culture

  A specific format

  Default (current) culture

  A specific format

  A specific culture

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  For more information about formatting, see Formatting Types.

  The parameter is an implementation whose method returns a object. Typically, is a object or a object. The object provides culture-specific information about the format of the string returned by this method. If is null, this instance is formatted with the object for the current culture.

  Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

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

  An that supplies culture-specific formatting information. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` is invalid.

  This example demonstrates converting a to a string.

  `using System; public class Int16ToStringExample { public static void Main() { Int16 i = 16; Console.WriteLine(i); string[] formats = {"c", "d", "e", "f", "g", "n", "p", "x" }; foreach(string str in formats) Console.WriteLine("{0}: {1}", str, i.ToString(str)); } }`

  The output is

  16

  c: $16.00

  d: 16

  e: 1.600000e+001

  f: 16.00

  g: 16

  n: 16.00

  p: 1,600.00 %

  x: 10

  The method formats an value in a specified format by using a object that represents the conventions of the current culture. If you want to use the default ("G", or general) format or specify a different culture, use the other overloads of the method, as follows:

  To use format

  For culture

  Use the overload

  Default ("G") format

  Default (current) culture

  Default ("G") format

  A specific culture

  A specific format

  A specific culture

  The parameter can be either a standard or a custom numeric format string. All standard numeric format strings other than "R" (or "r") are supported, as are all custom numeric format characters. If is null or an empty string, the return value of this instance is formatted with the general numeric format specifier ("G").

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  For more information about formatting, see Formatting Types.

  The return value of this instance is formatted with the for the current culture.

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

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

  A numeric format string. 0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.String `` `` is invalid. A numeric format string.

  The method formats an value in a specified format by using the object of a specified culture. If you want to use default format or culture settings, use the other overloads of the method, as follows:

  To use format

  For culture

  Use the overload

  Default ("G") format

  Default (current) culture

  Default ("G") format

  A specific culture

  A specific format

  Default (current) culture

  The parameter can be either a standard or a custom numeric format string. All standard numeric format strings other than "R" (or "r") are supported, as are all custom numeric format characters. If is null or an empty string (""), the string returned by this method is formatted with the general numeric format specifier ("G").

  The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  For more information about formatting, see Formatting Types.

  The parameter is an implementation. Its method returns a object that provides culture-specific information about the format of the string that is returned by this method. The object that implements can be any of the following:

  A object that represents the culture whose formatting rules are to be used.

  A object that contains specific numeric formatting information for this value.

  A custom object that implements .

  If is null, or a object cannot be obtained from , the return value is formatted with the for the current culture.

  Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific formatting information.

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

  A numeric format string. An object that supplies culture-specific formatting information. 0
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  2.0.0.0
  4.0.0.0
  System.Boolean `` `` `` `` To be added. To be added. To be added. To be added. To be added. To be added. To be added.
0