Skip to content

Instantly share code, notes, and snippets.

@MelbourneDeveloper
Created April 30, 2021 00:02
Show Gist options
  • Select an option

  • Save MelbourneDeveloper/012d0dc77b336c8e427cb3787e883b7c to your computer and use it in GitHub Desktop.

Select an option

Save MelbourneDeveloper/012d0dc77b336c8e427cb3787e883b7c to your computer and use it in GitHub Desktop.
Query Parameter
using System.Net;
namespace Urls
{
public record QueryParameter
{
private string? fieldValue;
public string FieldName { get; init; }
public string? Value
{
get => fieldValue; init
{
fieldValue = WebUtility.UrlDecode(value);
}
}
public QueryParameter(string fieldName, string? value)
{
FieldName = fieldName;
fieldValue = WebUtility.UrlDecode(value);
}
public override string ToString()
=> $"{FieldName}{(Value != null ? "=" : "")}{WebUtility.UrlEncode(Value)}";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment