C# – Validate an IP address
Use IPAddress.Parse() to parse an IP address from a string. This handles both IPv4 and IPv6 addresses and throws an exception if the string can’t be parsed into a valid IP address. Here’s an example: This outputs the following: Use IPAddress.TryParse() if you don’t want exceptions to be thrown. It returns false if the string … Read more