Skip to content

[API Proposal]: IPAddress should implement ISpanFormattable/Parsable<IPAddress> #82842

Closed
@stephentoub

Description

@stephentoub

Background and motivation

IPAddress already provides TryFormat/TryParse methods. It should implement the appropriate interfaces to go along with these. Doing that for IPAddress, for example, means the IPAddress's TryFormat will be used as part of string interpolation rather than its ToString() being used.

API Proposal

namespace System.Net

public class IPAddress
+    : ISpanFormattable, ISpanParsable<IPAddress>
{
    // all of the interface members implemented explicitly
}

API Usage

IPAddress address = ...;
string s = $"The address is {address}";

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions