C# Convert ToSByte() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Convert

Definition

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);
CallWhat 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

ParameterDescription
valueRequired. Text or number to convert.
fromBaseOptional. 2, 8, 10, or 16.

Return Value

Return ValueDescription
sbyteSigned 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);
    }
}

How It Works

  1. Signed text. Leading minus is kept.
  2. −12 stored. Fits easily in sbyte.
  3. Add two. Result −10 prints next.
  4. 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));
    }
}

How It Works

  1. Max decimal. 127 is sbyte.MaxValue.
  2. Hex 7F. Same value via base 16.
  3. Edge ok. Exactly 127 does not overflow.
  4. 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));
    }
}

How It Works

  1. −200 overflows. Below sbyte.MinValue.
  2. Catch it. Print a friendly message.
  3. −128 ok. Minimum edge succeeds.
  4. Check bounds. Validate before converting when possible.

Frequently Asked Questions

−128 to 127.
sbyte is signed; byte is 0–255 only.
Yes for typical ToSByte overloads.
Yes—2, 8, 10, or 16.
Parse throws on null; Convert returns 0.

Next: ToSingle()

Convert a value to float (Single)—32-bit floating point with System.Convert.

ToSingle() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

7 people found this page helpful