Share via


Byte.ParseByte Method

Definition

Overloads

ParseByte(String)

Parses the string argument as a signed decimal byte.

ParseByte(String, Int32)

Parses the string argument as a signed byte in the radix specified by the second argument.

ParseByte(String)

Parses the string argument as a signed decimal byte.

[Android.Runtime.Register("parseByte", "(Ljava/lang/String;)B", "")]
public static sbyte ParseByte (string s);
[<Android.Runtime.Register("parseByte", "(Ljava/lang/String;)B", "")>]
static member ParseByte : string -> sbyte

Parameters

s
String

a String containing the byte representation to be parsed

Returns

the byte value represented by the argument in decimal

Attributes

Exceptions

if string can not be parsed as a byte value.

Remarks

Parses the string argument as a signed decimal byte. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u005Cu002D') to indicate a negative value or an ASCII plus sign '+' ('\u005Cu002B') to indicate a positive value. The resulting byte value is returned, exactly as if the argument and the radix 10 were given as arguments to the #parseByte(java.lang.String, int) method.

Java documentation for java.lang.Byte.parseByte(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

ParseByte(String, Int32)

Parses the string argument as a signed byte in the radix specified by the second argument.

[Android.Runtime.Register("parseByte", "(Ljava/lang/String;I)B", "")]
public static sbyte ParseByte (string s, int radix);
[<Android.Runtime.Register("parseByte", "(Ljava/lang/String;I)B", "")>]
static member ParseByte : string * int -> sbyte

Parameters

s
String

the String containing the byte representation to be parsed

radix
Int32

the radix to be used while parsing s

Returns

the byte value represented by the string argument in the specified radix

Attributes

Exceptions

if string can not be parsed as a byte value, or radix Character.MAX_RADIX.

Remarks

Parses the string argument as a signed byte in the radix specified by the second argument. The characters in the string must all be digits, of the specified radix (as determined by whether java.lang.Character#digit(char, int) returns a nonnegative value) except that the first character may be an ASCII minus sign '-' ('\u005Cu002D') to indicate a negative value or an ASCII plus sign '+' ('\u005Cu002B') to indicate a positive value. The resulting byte value is returned.

An exception of type NumberFormatException is thrown if any of the following situations occurs: <ul> <li> The first argument is null or is a string of length zero.

<li> The radix is either smaller than java.lang.Character#MIN_RADIX or larger than java.lang.Character#MAX_RADIX.

<li> Any character of the string is not a digit of the specified radix, except that the first character may be a minus sign '-' ('\u005Cu002D') or plus sign '+' ('\u005Cu002B') provided that the string is longer than length 1.

<li> The value represented by the string is not a value of type byte. </ul>

Java documentation for java.lang.Byte.parseByte(java.lang.String, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to