Skip to content

Instantly share code, notes, and snippets.

@jpolvora
Created October 27, 2017 14:54
Show Gist options
  • Save jpolvora/fd613cdc501eecec4c230ff405c2223d to your computer and use it in GitHub Desktop.
Save jpolvora/fd613cdc501eecec4c230ff405c2223d to your computer and use it in GitHub Desktop.
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