Szerkesztés

Megosztás a következőn keresztül:


IPAddress.TryParse Method

Definition

Overloads

TryParse(ReadOnlySpan<Char>, IPAddress)

Tries to parse a span of characters into a value.

TryParse(String, IPAddress)

Determines whether a string is a valid IP address.

TryParse(ReadOnlySpan<Char>, IPAddress)

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

Tries to parse a span of characters into a value.

public:
 static bool TryParse(ReadOnlySpan<char> ipSpan, [Runtime::InteropServices::Out] System::Net::IPAddress ^ % address);
public:
 static bool TryParse(ReadOnlySpan<char> ipString, [Runtime::InteropServices::Out] System::Net::IPAddress ^ % address);
public static bool TryParse (ReadOnlySpan<char> ipSpan, out System.Net.IPAddress? address);
public static bool TryParse (ReadOnlySpan<char> ipString, out System.Net.IPAddress address);
static member TryParse : ReadOnlySpan<char> * IPAddress -> bool
static member TryParse : ReadOnlySpan<char> * IPAddress -> bool
Public Shared Function TryParse (ipSpan As ReadOnlySpan(Of Char), ByRef address As IPAddress) As Boolean
Public Shared Function TryParse (ipString As ReadOnlySpan(Of Char), ByRef address As IPAddress) As Boolean

Parameters

ipStringipSpan
ReadOnlySpan<Char>

The byte span to parse.

address
IPAddress

When this method returns, the IPAddress version of the byte span.

Returns

true if ipSpan was able to be parsed as an IP address; otherwise, false.

Applies to

TryParse(String, IPAddress)

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

Determines whether a string is a valid IP address.

public:
 static bool TryParse(System::String ^ ipString, [Runtime::InteropServices::Out] System::Net::IPAddress ^ % address);
public static bool TryParse (string ipString, out System.Net.IPAddress address);
public static bool TryParse (string? ipString, out System.Net.IPAddress? address);
static member TryParse : string * IPAddress -> bool
Public Shared Function TryParse (ipString As String, ByRef address As IPAddress) As Boolean

Parameters

ipString
String

The string to parse.

address
IPAddress

The IPAddress version of the string.

Returns

true if ipString was able to be parsed as an IP address; otherwise, false.

Exceptions

ipString is null.

Remarks

The static TryParse method creates an IPAddress instance from an IP address expressed in dotted-quad notation for IPv4 and in colon-hexadecimal notation for IPv6.

The number of parts (each part is separated by a period) in ipString determines how the IP address is constructed. A one part address is stored directly in the network address. A two part address, convenient for specifying a class A address, puts the leading part in the first byte and the trailing part in the right-most three bytes of the network address. A three part address, convenient for specifying a class B address, puts the first part in the first byte, the second part in the second byte, and the final part in the right-most two bytes of the network address. For example:

Number of parts and example ipString IPv4 address for IPAddress
1 -- "65535" 0.0.255.255
2 -- "20.2" 20.0.0.2
2 -- "20.65535" 20.0.255.255
3 -- "128.1.2" 128.1.0.2
4 -- "1.1.1.10" 1.1.1.10
4 -- "1.1.1.010" 1.1.1.8
1 -- "0x2F" 0.0.0.47

Applies to