Editare

Partajați prin


IPNetwork Struct

Definition

Represents an IP network with an IPAddress containing the network prefix and an Int32 defining the prefix length.

public value class IPNetwork : IEquatable<System::Net::IPNetwork>, IParsable<System::Net::IPNetwork>, ISpanFormattable, ISpanParsable<System::Net::IPNetwork>, IUtf8SpanFormattable
public readonly struct IPNetwork : IEquatable<System.Net.IPNetwork>, IParsable<System.Net.IPNetwork>, ISpanFormattable, ISpanParsable<System.Net.IPNetwork>, IUtf8SpanFormattable
type IPNetwork = struct
    interface IFormattable
    interface IParsable<IPNetwork>
    interface ISpanFormattable
    interface ISpanParsable<IPNetwork>
    interface IUtf8SpanFormattable
Public Structure IPNetwork
Implements IEquatable(Of IPNetwork), IParsable(Of IPNetwork), ISpanFormattable, ISpanParsable(Of IPNetwork), IUtf8SpanFormattable
Inheritance
IPNetwork
Implements

Remarks

This type disallows arbitrary IP-address/prefix-length CIDR pairs. BaseAddress must be defined so that all bits after the network prefix are set to zero. In other words, BaseAddress is always the first usable address of the network. The constructor and the parsing methods will throw in case there are non-zero bits after the prefix.

Constructors

IPNetwork(IPAddress, Int32)

Initializes a new instance of the IPNetwork class with the specified IPAddress and prefix length.

Properties

BaseAddress

Gets the IPAddress that represents the prefix of the network.

PrefixLength

Gets the length of the network prefix in bits.

Methods

Contains(IPAddress)

Determines whether a given IPAddress is part of the network.

Equals(IPNetwork)

Indicates whether the current object is equal to another object of the same type.

Equals(Object)

Determines whether two IPNetwork instances are equal.

GetHashCode()

Returns the hash code for this instance.

Parse(ReadOnlySpan<Char>)

Converts a CIDR character span to an IPNetwork instance.

Parse(String)

Converts a CIDR String to an IPNetwork instance.

ToString()

Converts the instance to a string containing the IPNetwork's CIDR notation.

TryFormat(Span<Byte>, Int32)

Attempts to write the IPNetwork's CIDR notation to the given utf8Destination UTF-8 span and returns a value indicating whether the operation succeeded.

TryFormat(Span<Char>, Int32)

Attempts to write the IPNetwork's CIDR notation to the given destination span and returns a value indicating whether the operation succeeded.

TryParse(ReadOnlySpan<Char>, IPNetwork)

Converts the specified CIDR character span to an IPNetwork instance and returns a value indicating whether the conversion succeeded.

TryParse(String, IPNetwork)

Converts the specified CIDR string to an IPNetwork instance and returns a value indicating whether the conversion succeeded.

Operators

Equality(IPNetwork, IPNetwork)

Determines whether the specified instances of IPNetwork are equal.

Inequality(IPNetwork, IPNetwork)

Determines whether the specified instances of IPNetwork are not equal.

Explicit Interface Implementations

IFormattable.ToString(String, IFormatProvider)

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

IParsable<IPNetwork>.Parse(String, IFormatProvider)

Parses a string into a value.

IParsable<IPNetwork>.TryParse(String, IFormatProvider, IPNetwork)

Tries to parse a string into an IPNetwork.

ISpanFormattable.TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

Tries to format the value of the current instance into the provided span of characters.

ISpanParsable<IPNetwork>.Parse(ReadOnlySpan<Char>, IFormatProvider)

Parses a span of characters into a value.

ISpanParsable<IPNetwork>.TryParse(ReadOnlySpan<Char>, IFormatProvider, IPNetwork)

Tries to parse a span of characters into a value.

IUtf8SpanFormattable.TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

Tries to format the value of the current instance as UTF-8 into the provided span of bytes.

Applies to