Here’s the translation of the URL parsing example from Go to C#:
Our URL parsing program demonstrates how to parse and extract different components from a URL in C#.
Running our URL parsing program shows all the different pieces that we extracted.
This C# program demonstrates URL parsing using the System.Uri class, which provides similar functionality to Go’s url.Parse. The HttpUtility.ParseQueryString method is used to parse query parameters, returning a NameValueCollection which is similar to the map returned by Go’s url.ParseQuery.
Note that C# doesn’t have a direct equivalent to Go’s net.SplitHostPort, but the Uri class provides separate properties for the host and port, making it unnecessary in this case.
Remember to add a reference to System.Web in your project file or use the appropriate NuGet package to access the HttpUtility class.