Created
April 30, 2021 00:02
-
-
Save MelbourneDeveloper/012d0dc77b336c8e427cb3787e883b7c to your computer and use it in GitHub Desktop.
Query Parameter
This file contains hidden or 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