Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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