In C#, Convert.ToSByte returns an sbyte—signed 8-bit integer from −128 to 127.
It mirrors ToByte but allows negative values. Overflow and bad format throw.
This is a static member of System.Convert. You call it with the type name, such as Convert.ToSByte(...). Convert is the everyday API for converting between common CLR types in C#.
Syntax
Convert text or numbers into an sbyte.
C#
sbyte a = Convert.ToSByte("-5");
sbyte b = Convert.ToSByte(100);
sbyte c = Convert.ToSByte("7F", 16);
Call
What it does
Convert.ToSByte("-5")
Negative decimal string.
Convert.ToSByte("7F", 16)
Hex with base 16 → 127.
null → 0. Range is −128…127. Prefer sbyte.TryParse for soft failure.
Library declarations
C#
public static sbyte ToSByte(string? value);
public static sbyte ToSByte(string? value, int fromBase);
public static sbyte ToSByte(int value);
Parameters
Parameter
Description
value
Required. Text or number to convert.
fromBase
Optional. 2, 8, 10, or 16.
Return Value
Return Value
Description
sbyte
Signed 8-bit result.
C# Examples
Example 1 — Parse a Negative SByte
Convert a small negative string.
C#
using System;
class Program {
static void Main() {
sbyte n = Convert.ToSByte("-12");
Console.WriteLine(n);
Console.WriteLine(n + 2);
}
}
Output
-12
-10
How It Works
Signed text. Leading minus is kept.
−12 stored. Fits easily in sbyte.
Add two. Result −10 prints next.
Unlike byte. ToByte would reject negatives.
Example 2 — Upper Edge 127
Show the maximum sbyte value.
C#
using System;
class Program {
static void Main() {
sbyte n = Convert.ToSByte("127");
Console.WriteLine(n);
Console.WriteLine(Convert.ToSByte("7F", 16));
}
}
Output
127
127
How It Works
Max decimal. 127 is sbyte.MaxValue.
Hex 7F. Same value via base 16.
Edge ok. Exactly 127 does not overflow.
128 fails. One more would throw OverflowException.
Example 3 — Catch Too Small
Handle a value below −128.
C#
using System;
class Program {
static void Main() {
try {
Console.WriteLine(Convert.ToSByte(-200));
} catch (OverflowException) {
Console.WriteLine("too small");
}
Console.WriteLine(Convert.ToSByte(-128));
}
}
Output
too small
-128
How It Works
−200 overflows. Below sbyte.MinValue.
Catch it. Print a friendly message.
−128 ok. Minimum edge succeeds.
Check bounds. Validate before converting when possible.