Posts

Showing posts from August, 2024

Query String Builder V1

public static string BuildUrlWithQueryString ( string baseUrl, NameValueCollection parameters ) { var queryString = string .Join( "&" , parameters.AllKeys .Select(key => string .IsNullOrEmpty(parameters[key]) ? HttpUtility.UrlEncode(key) : $" {HttpUtility.UrlEncode(key)} = {HttpUtility.UrlEncode(parameters[key])} " )); return string .IsNullOrEmpty(queryString) ? baseUrl : $" {baseUrl} ? {queryString} " ; }