IntPtr.ToString Method

Definition

Converts the numeric value of the current IntPtr object to its equivalent string representation.

Overloads

ToString()

Converts the numeric value of the current IntPtr object to its equivalent string representation.

ToString(IFormatProvider)

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

ToString(String)

Converts the numeric value of the current IntPtr object to its equivalent string representation.

ToString(String, IFormatProvider)

Formats the value of the current instance using the specified format.

ToString()

Source:
IntPtr.cs
Source:
IntPtr.cs
Source:
IntPtr.cs

Converts the numeric value of the current IntPtr object to its equivalent string representation.

public override string ToString ();

Returns

The string representation of the value of this instance.

Remarks

If the value of the Size property for this instance is 4, then this method is equivalent to Int32.ToString; otherwise, this method is equivalent to Int64.ToString.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

ToString(IFormatProvider)

Source:
IntPtr.cs
Source:
IntPtr.cs
Source:
IntPtr.cs

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

public string ToString (IFormatProvider? provider);

Parameters

provider
IFormatProvider

An object that supplies culture-specific formatting information.

Returns

The string representation of the value of this instance as specified by provider.

Applies to

.NET 9 and other versions
Product Versions
.NET 5, 6, 7, 8, 9

ToString(String)

Source:
IntPtr.cs
Source:
IntPtr.cs
Source:
IntPtr.cs

Converts the numeric value of the current IntPtr object to its equivalent string representation.

public string ToString (string format);
public string ToString (string? format);

Parameters

format
String

A format specification that governs how the current IntPtr object is converted.

Returns

The string representation of the value of the current IntPtr object.

Exceptions

format is invalid or not supported.

Remarks

If the format parameter is null or an empty string (""), the return value is formatted with the general format specifier ("G"). For more information about numeric format specifiers, see the Standard Numeric Format Strings topic.

The return value is formatted using the invariant culture.

See also

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

ToString(String, IFormatProvider)

Source:
IntPtr.cs
Source:
IntPtr.cs
Source:
IntPtr.cs

Formats the value of the current instance using the specified format.

public string ToString (string? format, IFormatProvider? provider);

Parameters

format
String

The format to use. -or- A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

provider
IFormatProvider

An object that supplies culture-specific formatting information.

Returns

The value of the current instance in the specified format.

Implements

Applies to

.NET 9 and other versions
Product Versions
.NET 5, 6, 7, 8, 9