IPAddress Constructors
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the IPAddress class.
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. |
- Source:
- IPAddress.cs
- Source:
- IPAddress.cs
- Source:
- IPAddress.cs
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
.NET 10 and other versions
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
- Source:
- IPAddress.cs
- Source:
- IPAddress.cs
- Source:
- IPAddress.cs
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
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
.NET 10 and other versions
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
- 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
.NET 10 and other versions
Product | Versions |
---|---|
.NET | Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Standard | 2.1 |
- Source:
- IPAddress.cs
- Source:
- IPAddress.cs
- Source:
- IPAddress.cs
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.
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
.NET 10 and other versions
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
- 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.
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
.NET 10 and other versions
Product | Versions |
---|---|
.NET | Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Standard | 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: