Class IpHelper
Provides utility methods for working with IP addresses and their numeric representations.
Inherited Members
Namespace: mk.helpers
Assembly: mk.helpers.dll
Syntax
public static class IpHelper
Methods
IpAddressToNumber(string)
Converts an IP address string to its corresponding numeric representation.
Declaration
public static long IpAddressToNumber(string address)
Parameters
| Type | Name | Description |
|---|---|---|
| string | address | The IP address string to convert. |
Returns
| Type | Description |
|---|---|
| long | The numeric representation of the IP address. |
IsValid(string)
Checks if the provided IP address is valid.
Declaration
public static bool IsValid(string ipAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| string | ipAddress | The IP address to validate. |
Returns
| Type | Description |
|---|---|
| bool | True if the IP address is valid; otherwise, false. |
IsValidIpv4(string)
Checks if the provided IP address is a valid IPv4 address.
Declaration
public static bool IsValidIpv4(string ipAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| string | ipAddress | The IP address to validate. |
Returns
| Type | Description |
|---|---|
| bool | True if the IP address is a valid IPv4 address; otherwise, false. |
IsValidIpv6(string)
Checks if the provided IP address is a valid IPv6 address.
Declaration
public static bool IsValidIpv6(string ipAddress)
Parameters
| Type | Name | Description |
|---|---|---|
| string | ipAddress | The IP address to validate. |
Returns
| Type | Description |
|---|---|
| bool | True if the IP address is a valid IPv6 address; otherwise, false. |
NumberToIpAddress(long)
Converts a numeric IP address representation to its corresponding string representation.
Declaration
public static string NumberToIpAddress(long address)
Parameters
| Type | Name | Description |
|---|---|---|
| long | address | The numeric IP address to convert. |
Returns
| Type | Description |
|---|---|
| string | The string representation of the IP address. |