The method Uri.TryCreate can be used to check if string is a valid URL or not in C#.
Uri newUrl = null;
if (!string.IsNullOrEmpty(oldUrl) && Uri.TryCreate(oldUrl, UriKind.Absolute, out newUrl)
{
//valid URL
}
© 2024 Digcode.com