Query Parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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