Created
October 27, 2017 14:54
-
-
Save jpolvora/fd613cdc501eecec4c230ff405c2223d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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