UrlSearchParams Class

https://url.spec.whatwg.org/#interface-urlsearchparams

public sealed class UrlSearchParams : IEnumerable<KeyValuePair<string, string>>, IEnumerable
Implements

Constructors

NameDescription
UrlSearchParams()Creates an empty list of name-value pairs.
UrlSearchParams(IEnumerable<IReadOnlyList<string>>)Initializes the object from a sequence of name-value pairs (each inner sequence must have exactly two items).
UrlSearchParams(IEnumerable<KeyValuePair<string, string>>)Initializes the object from a record.
UrlSearchParams(string)Creates a list of name-value pairs by parsing the given query string, ignoring a leading ?.

UrlSearchParams overloads

UrlSearchParams()

UrlSearchParams.cs

Creates an empty list of name-value pairs.

public UrlSearchParams()

UrlSearchParams(IEnumerable<IReadOnlyList<string>>)

UrlSearchParams.cs

Initializes the object from a sequence of name-value pairs (each inner sequence must have exactly two items).

public UrlSearchParams(IEnumerable<IReadOnlyList<string>> init)

UrlSearchParams(IEnumerable<KeyValuePair<string, string>>)

UrlSearchParams.cs

Initializes the object from a record.

public UrlSearchParams(IEnumerable<KeyValuePair<string, string>> init)

UrlSearchParams(string)

UrlSearchParams.cs

Creates a list of name-value pairs by parsing the given query string, ignoring a leading ?.

public UrlSearchParams(string init)

Properties

NameDescription
SizeGets the number of name-value pairs.

Gets the number of name-value pairs.

public uint Size { get; }

Methods

NameDescription
Append(string, string)Appends a name-value pair.
Delete(string, string?)Removes the pairs with the given name, and the given value if specified.
Get(string)Returns the value of the first pair with the given name, or null when there is none.
GetAll(string)Returns the values of all the pairs with the given name.
GetEnumerator()Returns an enumerator over the name-value pairs.
Has(string, string?)Returns whether a pair with the given name, and the given value if specified, exists.
Set(string, string)Sets the value of the first pair with the given name and removes the other ones, or appends a pair when there is none.
Sort()Sorts the name-value pairs by name, comparing code units (stable sort).
System.Collections.IEnumerable.GetEnumerator()
ToString()Stringification behavior: https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior

Append(string, string)

UrlSearchParams.cs

Appends a name-value pair.

public void Append(string name, string value)

Delete(string, string?)

UrlSearchParams.cs

Removes the pairs with the given name, and the given value if specified.

public void Delete(string name, string? value = null)

Returns the value of the first pair with the given name, or null when there is none.

public string? Get(string name)

GetAll(string)

UrlSearchParams.cs

Returns the values of all the pairs with the given name.

public IReadOnlyList<string> GetAll(string name)

GetEnumerator()

UrlSearchParams.cs

Returns an enumerator over the name-value pairs.

public IEnumerator<KeyValuePair<string, string>> GetEnumerator()

Has(string, string?)

UrlSearchParams.cs

Returns whether a pair with the given name, and the given value if specified, exists.

public bool Has(string name, string? value = null)

Set(string, string)

UrlSearchParams.cs

Sets the value of the first pair with the given name and removes the other ones, or appends a pair when there is none.

public void Set(string name, string value)

Sorts the name-value pairs by name, comparing code units (stable sort).

public void Sort()

System.Collections.IEnumerable.GetEnumerator()

UrlSearchParams.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.

Stringification behavior: https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior

public override string ToString()

Returns

string