IPAddress.TryFormat Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

TryFormat(Span<Char>, Int32)

Tries to format the current IP address into the provided span.

TryFormat(Span<Byte>, Int32)

Tries to format the current IP address into the provided span.

TryFormat(Span<Char>, Int32)

Source:
IPAddress.cs
Source:
IPAddress.cs
Source:
IPAddress.cs

Tries to format the current IP address into the provided span.

C#
public bool TryFormat(Span<char> destination, out int charsWritten);

Parameters

destination
Span<Char>

When this method returns, the IP address as a span of characters.

charsWritten
Int32

When this method returns, the number of characters written into the span.

Returns

true if the formatting was successful; otherwise, false.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

TryFormat(Span<Byte>, Int32)

Source:
IPAddress.cs
Source:
IPAddress.cs

Tries to format the current IP address into the provided span.

C#
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten);

Parameters

utf8Destination
Span<Byte>

The span into which to write the IP address as a span of UTF-8 bytes.

bytesWritten
Int32

When this method returns, contains the number of bytes written into the utf8Destination.

Returns

true if the formatting was successful; otherwise, false.

Applies to

.NET 10 and other versions
Product Versions
.NET 8, 9, 10