Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

struct System.​Net.​IPNetwork

Assembly: System.Net.Primitives

Implemented Interfaces

Represents an IP network with an <see cref="T:System.Net.IPAddress" /> containing the network prefix and an <see cref="T:System.Int32" /> defining the prefix length.

Properties

public IPAddress
BaseAddress
Gets the <see cref="T:System.Net.IPAddress" /> that represents the prefix of the network.
public int
PrefixLength
Gets the length of the network prefix in bits.

Methods

public bool
Contains​(IPAddress address)
Determines whether a given <see cref="T:System.Net.IPAddress" /> is part of the network.
Returns <see langword="true" /> if the <see cref="T:System.Net.IPAddress" /> is part of the network; otherwise, <see langword="false" /> .
address The <see cref="T:System.Net.IPAddress" /> to check.
public bool
Equals​(IPNetwork other)
Indicates whether the current object is equal to another object of the same type.
Returns <see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise, <see langword="false" /> .
other An object to compare with this object.
public bool
Equals​(object obj)
Determines whether two <see cref="T:System.Net.IPNetwork" /> instances are equal.
Returns <see langword="true" /> if <paramref name="obj" /> is an <see cref="T:System.Net.IPNetwork" /> instance and the networks are equal; otherwise <see langword="false" /> .
obj The <see cref="T:System.Net.IPNetwork" /> instance to compare to this instance.
public int
GetHashCode​()
Returns the hash code for this instance.
Returns An integer hash value.
public static IPNetwork
Parse​(ReadOnlySpan<​char> s)
Converts a CIDR character span to an <see cref="T:System.Net.IPNetwork" /> instance.
Returns An <see cref="T:System.Net.IPNetwork" /> instance.
s A character span that defines an IP network in CIDR notation.
public static IPNetwork
Parse​(string s)
Converts a CIDR <see cref="T:System.String" /> to an <see cref="T:System.Net.IPNetwork" /> instance.
Returns An <see cref="T:System.Net.IPNetwork" /> instance.
s A <see cref="T:System.String" /> that defines an IP network in CIDR notation.
public static IPNetwork
Parse​(ReadOnlySpan<​byte> utf8Text)
Converts a UTF-8 CIDR character span to an <see cref="T:System.Net.IPNetwork" /> instance.
Returns An <see cref="T:System.Net.IPNetwork" /> instance.
utf8Text A UTF-8 character span that defines an IP network in CIDR notation.
public string
ToString​()
Converts the instance to a string containing the <see cref="T:System.Net.IPNetwork" /> 's CIDR notation.
Returns The <see cref="T:System.String" /> containing the <see cref="T:System.Net.IPNetwork" /> 's CIDR notation.
public bool
TryFormat​(Span<​char> destination, Int32& charsWritten)
public bool
TryFormat​(Span<​byte> utf8Destination, Int32& bytesWritten)
public static bool
TryParse​(ReadOnlySpan<​char> s, IPNetwork& result)
public static bool
TryParse​(string s, IPNetwork& result)
public static bool
TryParse​(ReadOnlySpan<​byte> utf8Text, IPNetwork& result)
protected void
Finalize​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object