In C#, Convert.ToInt16 returns a short (16-bit signed integer) from text or other numeric types.
The range is −32,768 to 32,767. Outside that range throws OverflowException. Unreadable text throws FormatException.
This is a static member of System.Convert. You call it with the type name, such as Convert.ToInt16(...). Convert is the everyday API for converting between common CLR types in C#.
Syntax
Convert text or numbers into a short.
C#
short a = Convert.ToInt16("1000");
short b = Convert.ToInt16(-5);
short c = Convert.ToInt16("1F", 16);
Call
What it does
Convert.ToInt16("1000")
Decimal string → short.
Convert.ToInt16("1F", 16)
Hex string with base 16.
null → 0. Prefer short.TryParse for untrusted input. Base overload accepts 2, 8, 10, 16.
Library declarations
C#
public static short ToInt16(string? value);
public static short ToInt16(string? value, int fromBase);
public static short ToInt16(int value);
Parameters
Parameter
Description
value
Required. Text or number to convert.
fromBase
Optional. 2, 8, 10, or 16.
Return Value
Return Value
Description
short
16-bit signed result.
C# Examples
Example 1 — Parse a Short
Convert a decimal string to Int16.
C#
using System;
class Program {
static void Main() {
short n = Convert.ToInt16("250");
Console.WriteLine(n);
Console.WriteLine(n + 10);
}
}
Output
250
260
How It Works
Short width. Result type is 16-bit signed.
250 fits. Well inside ±32767.
Add ten. Shows numeric math on the result.
Null friendly. Convert yields 0 for null numeric inputs.
Example 2 — Hex to Short
Parse a hex string with fromBase 16.
C#
using System;
class Program {
static void Main() {
short n = Convert.ToInt16("7FFF", 16);
Console.WriteLine(n);
Console.WriteLine(Convert.ToInt16("1010", 2));
}
}
Output
32767
10
How It Works
7FFF hex. Max positive Int16 value 32767.
Binary 1010. Base 2 yields decimal 10.
Same method. fromBase selects the digit alphabet.
Overflow still applies. Values beyond short range throw.
Example 3 — Catch Out-of-Range
Handle a value too large for Int16.
C#
using System;
class Program {
static void Main() {
try {
Console.WriteLine(Convert.ToInt16(40000));
} catch (OverflowException) {
Console.WriteLine("outside Int16");
}
Console.WriteLine(Convert.ToInt16(32000));
}
}