Struct sbyte
- Namespace
- System
- Assembly
- mscorlib.dll
Represents an 8-bit signed integer.
[CLSCompliant(false)]
public sbyte
- Inherited Members
Fields
MaxValue
Represents the largest possible value of SByte. This field is constant.
public const sbyte MaxValue = 127
Field Value
Remarks
The value of this constant is 127; that is, hexadecimal 0x7F.
MinValue
Represents the smallest possible value of SByte. This field is constant.
public const sbyte MinValue = -128
Field Value
Remarks
The value of this constant is -128; that is, hexadecimal 0x80.
Methods
Parse(string)
Converts the string representation of a number to its 8-bit signed integer equivalent.
[CLSCompliant(false)]
public static sbyte Parse(string s)
Parameters
s
stringA string that represents a number to convert. The string is interpreted using the NumberStyles.Integer style.
Returns
- sbyte
An 8-bit signed integer that is equivalent to the number contained in the s parameter.
Exceptions
- ArgumentNullException
s
is null.
ToString()
Converts the numeric value of this instance to its equivalent string representation.
public override string ToString()
Returns
- string
The string representation of the value of this instance, consisting of a negative sign if the value is negative, and a sequence of digits ranging from 0 to 9 with no leading zeroes.
ToString(string)
Converts the numeric value of this instance to its equivalent string representation, using the specified format.
public string ToString(string format)
Parameters
format
stringA standard or custom numeric format string.
Returns
- string
The string representation of the value of this instance as specified by format.
TryParse(string, out sbyte)
Tries to convert the string representation of a number to its sbyte equivalent, and returns a value that indicates whether the conversion succeeded.
[CLSCompliant(false)]
public static bool TryParse(string s, out sbyte result)
Parameters
s
stringA string that contains a number to convert.
result
sbyteWhen this method returns, contains the 8-bit signed integer value that is equivalent to the number contained in
s
if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null or Empty, is not in the correct format, or represents a number that is less than MinValue or greater than MaxValue. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.
Returns
Remarks
The TryParse(string, out sbyte)(String, SByte) method is like the Parse(string)(String) method, except that it does not throw an exception if the conversion fails. This method eliminates the need to use exception handling to test for a FormatException if value is invalid and cannot be successfully parsed.