Skip to content

Instantly share code, notes, and snippets.

@jindeveloper
Created June 9, 2019 14:08
Show Gist options
  • Save jindeveloper/891905ba1501ba42a0e6139c21730924 to your computer and use it in GitHub Desktop.
Save jindeveloper/891905ba1501ba42a0e6139c21730924 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
string address = "https://www.google.com/webhp?hl=fil&sa=X&ved=0ahUKEwiC9fW2rtziAhWGF4gKHeYaC6kQPAgH";
Uri uriGoogle = new Uri(address);
PrintInfo(uriGoogle);
UriBuilder reBuildGoogle = new UriBuilder(uriGoogle.Scheme, uriGoogle.Host, uriGoogle.Port, uriGoogle.PathAndQuery);
Console.WriteLine($"{Uri.EscapeDataString(reBuildGoogle.ToString())}");
}
static void PrintInfo(Uri uri)
{
Console.WriteLine($"Absolute Uri/URL: {uri.AbsoluteUri}");
Console.WriteLine($"Absolute Uri/URL: {Uri.EscapeDataString(uri.AbsoluteUri)}");
Console.WriteLine($"Port {uri.Port}");
Console.WriteLine($"Is using default port: {uri.IsDefaultPort}");
Console.WriteLine($"Protocol: {uri.Scheme}"); //Scheme property gets the protocol
Console.WriteLine($"Host: {uri.Host}");
Console.WriteLine($"Query: {uri.Query}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment