IPAddress 建構函式

定義

初始化 IPAddress 類別的新執行個體。Initializes a new instance of the IPAddress class.

多載

IPAddress(Byte[])

使用指定為 IPAddress 陣列的位址,初始化 Byte 類別的新執行個體。Initializes a new instance of the IPAddress class with the address specified as a Byte array.

IPAddress(Int64)

使用指定為 IPAddress 的位址,初始化 Int64 類別的新執行個體。Initializes a new instance of the IPAddress class with the address specified as an Int64.

IPAddress(ReadOnlySpan<Byte>)

使用指定為位元組範圍的位址,初始化 IPAddress 類別的新執行個體。Initializes a new instance of the IPAddress class with the address specified as a byte span.

IPAddress(Byte[], Int64)

使用指定為 IPAddress 陣列且具有指定之範圍識別項的位址,初始化 Byte 類別的新執行個體。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)

使用指定為位元組範圍且具有指定範圍識別碼的位址,初始化 IPAddress 類別的新執行個體。Initializes a new instance of the IPAddress class with the address specified as a byte span and the specified scope identifier.

IPAddress(Byte[])

使用指定為 IPAddress 陣列的位址,初始化 Byte 類別的新執行個體。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())

參數

address
Byte[]

IP 位址的位元組陣列值。The byte array value of the IP address.

例外狀況

addressnulladdress is null.

address 包含錯誤的 IP 位址。address contains a bad IP address.

備註

建立 IPAddress 時,會將 Address 屬性設定為 addressThe IPAddress is created with the Address property set to address.

如果 address 的長度為4,IPAddress(Byte[]) 會建立 IPv4 位址;否則,會構造範圍為0的 IPv6 位址。If the length of address is 4, IPAddress(Byte[]) constructs an IPv4 address; otherwise, an IPv6 address with a scope of 0 is constructed.

在索引位置0中,會假設 Byte 陣列是以網路位元組順序排序,且最大的位元組是第一個。The Byte array is assumed to be in network byte order with the most significant byte first in index position 0.

IPAddress(Int64)

使用指定為 IPAddress 的位址,初始化 Int64 類別的新執行個體。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)

參數

newAddress
Int64

IP 位址的長整數值。The long value of the IP address. 例如,位元組由大到小格式的 0x2414188f 值將為 IP 位址 "143.24.20.36"。For example, the value 0x2414188f in big-endian format would be the IP address "143.24.20.36".

例外狀況

newAddress < 0 或newAddress < 0 or newAddress > 0x00000000FFFFFFFFnewAddress > 0x00000000FFFFFFFF

備註

建立 IPAddress 實例時,會將 Address 屬性設為 newAddressThe IPAddress instance is created with the Address property set to newAddress.

Int64 值會假設為網路位元組順序。The Int64 value is assumed to be in network byte order.

IPAddress(ReadOnlySpan<Byte>)

使用指定為位元組範圍的位址,初始化 IPAddress 類別的新執行個體。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))

參數

address
ReadOnlySpan<Byte>

IP 位址的位元組表示法依網路位元組順序,並在索引位置 0 有最大顯著性位元組優先。The byte representation of the IP address, in network byte order, with the most significant byte first in index position 0.

例外狀況

address 包含錯誤的 IP 位址。address contains a bad IP address.

備註

建立 IPAddress 時,會將 Address 屬性設定為 addressThe IPAddress is created with the Address property set to address.

如果 address 的長度是4,則這個方法會建立 IPv4 位址;否則,會構造範圍為0的 IPv6 位址。If the length of address is 4, this method constructs an IPv4 address; otherwise, an IPv6 address with a scope of 0 is constructed.

IPAddress(Byte[], Int64)

使用指定為 IPAddress 陣列且具有指定之範圍識別項的位址,初始化 Byte 類別的新執行個體。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)

參數

address
Byte[]

IP 位址的位元組陣列值。The byte array value of the IP address.

scopeid
Int64

範圍識別項的長整數值。The long value of the scope identifier.

例外狀況

addressnulladdress is null.

address 包含錯誤的 IP 位址。address contains a bad IP address.

scopeid < 0 或scopeid < 0 or scopeid > 0x00000000FFFFFFFFscopeid > 0x00000000FFFFFFFF

備註

此函式會具現化 IPv6 位址。This constructor instantiates an IPv6 address. scopeid 會在連結-本機位址的情況下識別網路介面。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.

在索引位置0中,會假設 Byte 陣列是以網路位元組順序排序,且最大的位元組是第一個。The Byte array is assumed to be in network byte order with the most significant byte first in index position 0.

IPAddress(ReadOnlySpan<Byte>, Int64)

使用指定為位元組範圍且具有指定範圍識別碼的位址,初始化 IPAddress 類別的新執行個體。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)

參數

address
ReadOnlySpan<Byte>

IP 位址的位元組範圍值。The byte span value of the IP address.

scopeid
Int64

範圍識別項的長整數值。The long value of the scope identifier.

例外狀況

address 包含錯誤的 IP 位址。address contains a bad IP address.

scopeid < 0scopeid < 0

-或--or-

scopeid > 0x00000000FFFFFFFFscopeid > 0x00000000FFFFFFFF

備註

此函式會具現化 IPv6 位址。This constructor instantiates an IPv6 address. scopeid 會在連結-本機位址的情況下識別網路介面。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.

位元組範圍會假設為以網路位元組順序排序,且在索引位置0中的第一個最重要的位元組。The byte span is assumed to be in network byte order with the most significant byte first in index position 0.

適用於