Uredi

Deli z drugimi prek


IPAddress Constructors

Definition

Initializes a new instance of the IPAddress class.

Overloads

IPAddress(Byte[])

Initializes a new instance of the IPAddress class with the address specified as a Byte array.

IPAddress(Int64)

Initializes a new instance of the IPAddress class with the address specified as an Int64.

IPAddress(ReadOnlySpan<Byte>)

Initializes a new instance of the IPAddress class with the address specified as a byte span.

IPAddress(Byte[], Int64)

Initializes a new instance of the IPAddress class with the address specified as a Byte array and the specified scope identifier.

IPAddress(ReadOnlySpan<Byte>, Int64)

Initializes a new instance of the IPAddress class with the address specified as a byte span and the specified scope identifier.

IPAddress(Byte[])

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

Initializes a new instance of the IPAddress class with the address specified as a Byte array.

public:
 IPAddress(cli::array <System::Byte> ^ address);
public IPAddress (byte[] address);
new System.Net.IPAddress : byte[] -> System.Net.IPAddress
Public Sub New (address As Byte())

Parameters

address
Byte[]

The byte array value of the IP address.

Exceptions

address is null.

address contains a bad IP address.

Remarks

The IPAddress is created with the Address property set to address.

If the length of address is 4, IPAddress(Byte[]) constructs an IPv4 address; otherwise, an IPv6 address with a scope of 0 is constructed.

The Byte array is assumed to be in network byte order with the most significant byte first in index position 0.

Applies to

IPAddress(Int64)

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

Initializes a new instance of the IPAddress class with the address specified as an Int64.

public:
 IPAddress(long newAddress);
public IPAddress (long newAddress);
new System.Net.IPAddress : int64 -> System.Net.IPAddress
Public Sub New (newAddress As Long)

Parameters

newAddress
Int64

The long value of the IP address. For example, the value 0x2414188f in big-endian format would be the IP address "143.24.20.36".

Exceptions

newAddress < 0 or

newAddress > 0x00000000FFFFFFFF

Remarks

The IPAddress instance is created with the Address property set to newAddress.

The Int64 value is assumed to be in network byte order.

Applies to

IPAddress(ReadOnlySpan<Byte>)

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

Initializes a new instance of the IPAddress class with the address specified as a byte span.

public:
 IPAddress(ReadOnlySpan<System::Byte> address);
public IPAddress (ReadOnlySpan<byte> address);
new System.Net.IPAddress : ReadOnlySpan<byte> -> System.Net.IPAddress
Public Sub New (address As ReadOnlySpan(Of Byte))

Parameters

address
ReadOnlySpan<Byte>

The byte representation of the IP address, in network byte order, with the most significant byte first in index position 0.

Exceptions

address contains a bad IP address.

Remarks

The IPAddress is created with the Address property set to address.

If the length of address is 4, this method constructs an IPv4 address; otherwise, an IPv6 address with a scope of 0 is constructed.

Applies to

IPAddress(Byte[], Int64)

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

Initializes a new instance of the IPAddress class with the address specified as a Byte array and the specified scope identifier.

public:
 IPAddress(cli::array <System::Byte> ^ address, long scopeid);
public IPAddress (byte[] address, long scopeid);
new System.Net.IPAddress : byte[] * int64 -> System.Net.IPAddress
Public Sub New (address As Byte(), scopeid As Long)

Parameters

address
Byte[]

The byte array value of the IP address.

scopeid
Int64

The long value of the scope identifier.

Exceptions

address is null.

address contains a bad IP address.

scopeid < 0 or

scopeid > 0x00000000FFFFFFFF

Remarks

This constructor instantiates an IPv6 address. The scopeid identifies a network interface in the case of a link-local address. The scope is valid only for link-local and site-local addresses.

The Byte array is assumed to be in network byte order with the most significant byte first in index position 0.

Applies to

IPAddress(ReadOnlySpan<Byte>, Int64)

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

Initializes a new instance of the IPAddress class with the address specified as a byte span and the specified scope identifier.

public:
 IPAddress(ReadOnlySpan<System::Byte> address, long scopeid);
public IPAddress (ReadOnlySpan<byte> address, long scopeid);
new System.Net.IPAddress : ReadOnlySpan<byte> * int64 -> System.Net.IPAddress
Public Sub New (address As ReadOnlySpan(Of Byte), scopeid As Long)

Parameters

address
ReadOnlySpan<Byte>

The byte span value of the IP address.

scopeid
Int64

The long value of the scope identifier.

Exceptions

address contains a bad IP address.

scopeid < 0

-or-

scopeid > 0x00000000FFFFFFFF

Remarks

This constructor instantiates an IPv6 address. The scopeid identifies a network interface in the case of a link-local address. The scope is valid only for link-local and site-local addresses.

The byte span is assumed to be in network byte order with the most significant byte first in index position 0.

Applies to