SByte Struct

Definition

Important

This API is not CLS-compliant.

CLS-compliant alternative
System.Int16

Represents an 8-bit signed integer.

public value class System::SByte : IComparable, IComparable<System::SByte>, IConvertible, IEquatable<System::SByte>, IFormattable
public value class System::SByte : IComparable, IComparable<System::SByte>, IConvertible, IEquatable<System::SByte>, ISpanFormattable
public value class System::SByte : IComparable<System::SByte>, IConvertible, IEquatable<System::SByte>, IParsable<System::SByte>, ISpanParsable<System::SByte>, System::Numerics::IAdditionOperators<System::SByte, System::SByte, System::SByte>, System::Numerics::IAdditiveIdentity<System::SByte, System::SByte>, System::Numerics::IBinaryInteger<System::SByte>, System::Numerics::IBinaryNumber<System::SByte>, System::Numerics::IBitwiseOperators<System::SByte, System::SByte, System::SByte>, System::Numerics::IComparisonOperators<System::SByte, System::SByte, bool>, System::Numerics::IDecrementOperators<System::SByte>, System::Numerics::IDivisionOperators<System::SByte, System::SByte, System::SByte>, System::Numerics::IEqualityOperators<System::SByte, System::SByte, bool>, System::Numerics::IIncrementOperators<System::SByte>, System::Numerics::IMinMaxValue<System::SByte>, System::Numerics::IModulusOperators<System::SByte, System::SByte, System::SByte>, System::Numerics::IMultiplicativeIdentity<System::SByte, System::SByte>, System::Numerics::IMultiplyOperators<System::SByte, System::SByte, System::SByte>, System::Numerics::INumber<System::SByte>, System::Numerics::INumberBase<System::SByte>, System::Numerics::IShiftOperators<System::SByte, int, System::SByte>, System::Numerics::ISignedNumber<System::SByte>, System::Numerics::ISubtractionOperators<System::SByte, System::SByte, System::SByte>, System::Numerics::IUnaryNegationOperators<System::SByte, System::SByte>, System::Numerics::IUnaryPlusOperators<System::SByte, System::SByte>
public value class System::SByte : IComparable, IConvertible, IFormattable
public value class System::SByte : IComparable, IComparable<System::SByte>, IEquatable<System::SByte>, IFormattable
[System.CLSCompliant(false)]
public struct SByte : IComparable, IComparable<sbyte>, IConvertible, IEquatable<sbyte>, IFormattable
[System.CLSCompliant(false)]
public readonly struct SByte : IComparable, IComparable<sbyte>, IConvertible, IEquatable<sbyte>, IFormattable
[System.CLSCompliant(false)]
public readonly struct SByte : IComparable, IComparable<sbyte>, IConvertible, IEquatable<sbyte>, ISpanFormattable
[System.CLSCompliant(false)]
public readonly struct SByte : IComparable<sbyte>, IConvertible, IEquatable<sbyte>, IParsable<sbyte>, ISpanParsable<sbyte>, System.Numerics.IAdditionOperators<sbyte,sbyte,sbyte>, System.Numerics.IAdditiveIdentity<sbyte,sbyte>, System.Numerics.IBinaryInteger<sbyte>, System.Numerics.IBinaryNumber<sbyte>, System.Numerics.IBitwiseOperators<sbyte,sbyte,sbyte>, System.Numerics.IComparisonOperators<sbyte,sbyte,bool>, System.Numerics.IDecrementOperators<sbyte>, System.Numerics.IDivisionOperators<sbyte,sbyte,sbyte>, System.Numerics.IEqualityOperators<sbyte,sbyte,bool>, System.Numerics.IIncrementOperators<sbyte>, System.Numerics.IMinMaxValue<sbyte>, System.Numerics.IModulusOperators<sbyte,sbyte,sbyte>, System.Numerics.IMultiplicativeIdentity<sbyte,sbyte>, System.Numerics.IMultiplyOperators<sbyte,sbyte,sbyte>, System.Numerics.INumber<sbyte>, System.Numerics.INumberBase<sbyte>, System.Numerics.IShiftOperators<sbyte,int,sbyte>, System.Numerics.ISignedNumber<sbyte>, System.Numerics.ISubtractionOperators<sbyte,sbyte,sbyte>, System.Numerics.IUnaryNegationOperators<sbyte,sbyte>, System.Numerics.IUnaryPlusOperators<sbyte,sbyte>
[System.CLSCompliant(false)]
[System.Serializable]
public struct SByte : IComparable, IConvertible, IFormattable
[System.CLSCompliant(false)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct SByte : IComparable, IComparable<sbyte>, IConvertible, IEquatable<sbyte>, IFormattable
[System.CLSCompliant(false)]
public struct SByte : IComparable, IComparable<sbyte>, IEquatable<sbyte>, IFormattable
[<System.CLSCompliant(false)>]
type sbyte = struct
    interface IConvertible
    interface IFormattable
[<System.CLSCompliant(false)>]
type sbyte = struct
    interface IConvertible
    interface ISpanFormattable
    interface IFormattable
[<System.CLSCompliant(false)>]
type sbyte = struct
    interface IConvertible
    interface IFormattable
    interface IParsable<sbyte>
    interface ISpanFormattable
    interface ISpanParsable<sbyte>
    interface IAdditionOperators<sbyte, sbyte, sbyte>
    interface IAdditiveIdentity<sbyte, sbyte>
    interface IBinaryInteger<sbyte>
    interface IBinaryNumber<sbyte>
    interface IBitwiseOperators<sbyte, sbyte, sbyte>
    interface IComparisonOperators<sbyte, sbyte, bool>
    interface IEqualityOperators<sbyte, sbyte, bool>
    interface IDecrementOperators<sbyte>
    interface IDivisionOperators<sbyte, sbyte, sbyte>
    interface IIncrementOperators<sbyte>
    interface IModulusOperators<sbyte, sbyte, sbyte>
    interface IMultiplicativeIdentity<sbyte, sbyte>
    interface IMultiplyOperators<sbyte, sbyte, sbyte>
    interface INumber<sbyte>
    interface INumberBase<sbyte>
    interface ISubtractionOperators<sbyte, sbyte, sbyte>
    interface IUnaryNegationOperators<sbyte, sbyte>
    interface IUnaryPlusOperators<sbyte, sbyte>
    interface IShiftOperators<sbyte, int, sbyte>
    interface IMinMaxValue<sbyte>
    interface ISignedNumber<sbyte>
[<System.CLSCompliant(false)>]
[<System.Serializable>]
type sbyte = struct
    interface IFormattable
    interface IConvertible
[<System.CLSCompliant(false)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type sbyte = struct
    interface IFormattable
    interface IConvertible
[<System.CLSCompliant(false)>]
type sbyte = struct
    interface IFormattable
Public Structure SByte
Implements IComparable, IComparable(Of SByte), IConvertible, IEquatable(Of SByte), IFormattable
Public Structure SByte
Implements IComparable, IComparable(Of SByte), IConvertible, IEquatable(Of SByte), ISpanFormattable
Public Structure SByte
Implements IAdditionOperators(Of SByte, SByte, SByte), IAdditiveIdentity(Of SByte, SByte), IBinaryInteger(Of SByte), IBinaryNumber(Of SByte), IBitwiseOperators(Of SByte, SByte, SByte), IComparable(Of SByte), IComparisonOperators(Of SByte, SByte, Boolean), IConvertible, IDecrementOperators(Of SByte), IDivisionOperators(Of SByte, SByte, SByte), IEqualityOperators(Of SByte, SByte, Boolean), IEquatable(Of SByte), IIncrementOperators(Of SByte), IMinMaxValue(Of SByte), IModulusOperators(Of SByte, SByte, SByte), IMultiplicativeIdentity(Of SByte, SByte), IMultiplyOperators(Of SByte, SByte, SByte), INumber(Of SByte), INumberBase(Of SByte), IParsable(Of SByte), IShiftOperators(Of SByte, Integer, SByte), ISignedNumber(Of SByte), ISpanParsable(Of SByte), ISubtractionOperators(Of SByte, SByte, SByte), IUnaryNegationOperators(Of SByte, SByte), IUnaryPlusOperators(Of SByte, SByte)
Public Structure SByte
Implements IComparable, IConvertible, IFormattable
Public Structure SByte
Implements IComparable, IComparable(Of SByte), IEquatable(Of SByte), IFormattable
Inheritance
Attributes
Implements

Remarks

The SByte value type represents integers with values ranging from negative 128 to positive 127.

Important

The SByte type is not CLS-compliant. The CLS-compliant alternative type is Int16. Byte can be used instead to replace a positive SByte value that ranges from zero to MaxValue. For more information about CLS compliance, see Language Independence and Language-Independent Components.

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

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

Fields

MaxValue

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

MinValue

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

Methods

Abs(SByte)

Computes the absolute of a value.

Clamp(SByte, SByte, SByte)

Clamps a value to an inclusive minimum and maximum value.

CompareTo(Object)

Compares this instance to a specified object and returns an indication of their relative values.

CompareTo(SByte)

Compares this instance to a specified 8-bit signed integer and returns an indication of their relative values.

CopySign(SByte, SByte)

Copies the sign of a value to the sign of another value.

CreateChecked<TOther>(TOther)

Creates an instance of the current type from a value, throwing an overflow exception for any values that fall outside the representable range of the current type.

CreateSaturating<TOther>(TOther)

Creates an instance of the current type from a value, saturating any values that fall outside the representable range of the current type.

CreateTruncating<TOther>(TOther)

Creates an instance of the current type from a value, truncating any values that fall outside the representable range of the current type.

DivRem(SByte, SByte)

Computes the quotient and remainder of two values.

Equals(Object)

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

Equals(SByte)

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

GetHashCode()

Returns the hash code for this instance.

GetTypeCode()

Returns the TypeCode for value type SByte.

IsEvenInteger(SByte)

Determines if a value represents an even integral number.

IsNegative(SByte)

Determines if a value is negative.

IsOddInteger(SByte)

Determines if a value represents an odd integral number.

IsPositive(SByte)

Determines if a value is positive.

IsPow2(SByte)

Determines if a value is a power of two.

LeadingZeroCount(SByte)

Computes the number of leading zeros in a value.

Log2(SByte)

Computes the log2 of a value.

Max(SByte, SByte)

Compares two values to compute which is greater.

MaxMagnitude(SByte, SByte)

Compares two values to compute which is greater.

Min(SByte, SByte)

Compares two values to compute which is lesser.

MinMagnitude(SByte, SByte)

Compares two values to compute which is lesser.

Parse(ReadOnlySpan<Char>, IFormatProvider)

Parses a span of characters into a value.

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

Converts the span representation of a number that is in a specified style and culture-specific format to its 8-bit signed equivalent.

Parse(String)

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

Parse(String, IFormatProvider)

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

Parse(String, NumberStyles)

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

Parse(String, NumberStyles, IFormatProvider)

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

PopCount(SByte)

Computes the number of bits that are set in a value.

RotateLeft(SByte, Int32)

Rotates a value left by a given amount.

RotateRight(SByte, Int32)

Rotates a value right by a given amount.

Sign(SByte)

Computes the sign of a value.

ToString()

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

ToString(IFormatProvider)

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

ToString(String)

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

ToString(String, IFormatProvider)

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

TrailingZeroCount(SByte)

Computes the number of trailing zeros in a value.

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

Tries to format the value of the current 8-bit signed integer instance into the provided span of characters.

TryParse(ReadOnlySpan<Char>, IFormatProvider, SByte)

Tries to parse a span of characters into a value.

TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, SByte)

Tries to convert the span representation of a number in a specified style and culture-specific format to its SByte equivalent, and returns a value that indicates whether the conversion succeeded.

TryParse(ReadOnlySpan<Char>, SByte)

Tries to convert the span representation of a number to its SByte equivalent, and returns a value that indicates whether the conversion succeeded.

TryParse(String, IFormatProvider, SByte)

Tries to parse a string into a value.

TryParse(String, NumberStyles, IFormatProvider, SByte)

Tries to convert the string representation of a number in a specified style and culture-specific format to its SByte equivalent, and returns a value that indicates whether the conversion succeeded.

TryParse(String, SByte)

Tries to convert the string representation of a number to its SByte equivalent, and returns a value that indicates whether the conversion succeeded.

Explicit Interface Implementations

IBinaryInteger<SByte>.GetByteCount()

Gets the number of bytes that will be written as part of TryWriteLittleEndian(Span<Byte>, Int32).

IBinaryInteger<SByte>.GetShortestBitLength()

Gets the length, in bits, of the shortest two's complement representation of the current value.

IBinaryInteger<SByte>.TryWriteBigEndian(Span<Byte>, Int32)

Tries to write the current value, in big-endian format, to a given span.

IBinaryInteger<SByte>.TryWriteLittleEndian(Span<Byte>, Int32)

Tries to write the current value, in little-endian format, to a given span.

IComparable.CompareTo(Object)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

IConvertible.GetTypeCode()

Returns the TypeCode for this instance.

IConvertible.ToBoolean(IFormatProvider)

For a description of this member, see ToBoolean(IFormatProvider).

IConvertible.ToByte(IFormatProvider)

For a description of this member, see ToByte(IFormatProvider).

IConvertible.ToChar(IFormatProvider)

For a description of this member, see ToChar(IFormatProvider).

IConvertible.ToDateTime(IFormatProvider)

This conversion is not supported. Attempting to do so throws an InvalidCastException.

IConvertible.ToDecimal(IFormatProvider)

For a description of this member, see ToDecimal(IFormatProvider).

IConvertible.ToDouble(IFormatProvider)

For a description of this member, see ToDouble(IFormatProvider).

IConvertible.ToInt16(IFormatProvider)

For a description of this member, see ToInt16(IFormatProvider).

IConvertible.ToInt32(IFormatProvider)

For a description of this member, see ToInt32(IFormatProvider).

IConvertible.ToInt64(IFormatProvider)

For a description of this member, see ToInt64(IFormatProvider).

IConvertible.ToSByte(IFormatProvider)

For a description of this member, see ToSByte(IFormatProvider).

IConvertible.ToSingle(IFormatProvider)

For a description of this member, see ToSingle(IFormatProvider).

IConvertible.ToType(Type, IFormatProvider)

For a description of this member, see ToType(Type, IFormatProvider).

IConvertible.ToUInt16(IFormatProvider)

For a description of this member, see ToUInt16(IFormatProvider).

IConvertible.ToUInt32(IFormatProvider)

For a description of this member, see ToUInt32(IFormatProvider).

IConvertible.ToUInt64(IFormatProvider)

For a description of this member, see ToUInt64(IFormatProvider).

Applies to

Thread Safety

All members of this type are thread safe. Members that appear to modify instance state actually return a new instance initialized with the new value. As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.

See also