Integer.ToHexString(Int32) Method

Definition

Returns a string representation of the integer argument as an unsigned integer in base 16.

[Android.Runtime.Register("toHexString", "(I)Ljava/lang/String;", "")]
public static string ToHexString (int i);
[<Android.Runtime.Register("toHexString", "(I)Ljava/lang/String;", "")>]
static member ToHexString : int -> string

Parameters

i
Int32

an integer to be converted to a string.

Returns

the string representation of the unsigned integer value represented by the argument in hexadecimal (base&nbsp;16).

Attributes

Remarks

Returns a string representation of the integer argument as an unsigned integer in base&nbsp;16.

The unsigned integer value is the argument plus 2<sup>32</sup> if the argument is negative; otherwise, it is equal to the argument. This value is converted to a string of ASCII digits in hexadecimal (base&nbsp;16) with no extra leading 0s.

The value of the argument can be recovered from the returned string s by calling Integer#parseUnsignedInt(String, int) Integer.parseUnsignedInt(s, 16).

If the unsigned magnitude is zero, it is represented by a single zero character '0' ('\u005Cu0030'); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits:

<blockquote> 0123456789abcdef</blockquote>

These are the characters '\u005Cu0030' through '\u005Cu0039' and '\u005Cu0061' through '\u005Cu0066'. If uppercase letters are desired, the java.lang.String#toUpperCase() method may be called on the result:

<blockquote> Integer.toHexString(n).toUpperCase()</blockquote>

Added in 1.0.2.

Java documentation for java.lang.Integer.toHexString(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