Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bool isIPv4Address(string inputString) {
var split = inputString.Split('.');
if (split.Length != 4) return false;
for (int i = 0; i < 4; i++) {
var str = split[i];
int intVal;
if (!int.TryParse(str, out intVal)) return false;
if (intVal < 0 || intVal > 255) return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment