Created
June 18, 2014 07:59
-
-
Save hagbarddenstore/a799779bb2c7bf00013b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var text = txtserver.Text; | |
if (!string.IsNullOrEmpty(text)) | |
{ | |
IpAddress ipAddress; | |
Uri url; | |
if (IpAddress.TryParse(text, out ipAddress)) | |
{ | |
// Valid IP | |
} | |
else if (Uri.TryCreate(text, UriKind.Absolute, out url)) | |
{ | |
// Valid URI | |
} | |
else | |
{ | |
// Invalid IP or URI | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment