Table of Contents

Class URLSearchParams

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The URLSearchParams interface defines utility methods to work with the query string of a URL.

[Value("URLSearchParams")]
public class URLSearchParams
Inheritance
URLSearchParams
Inherited Members

Remarks

URLSearchParams objects are iterable, so they can directly be used in a Statements/forOf structure to iterate over key/value pairs in the same order as they appear in the query string, for example the following two lines are equivalent:

Although URLSearchParams is functionally similar to a Map, when iterating, it may suffer from some pitfalls that Map doesn't encounter due to how it's implemented.

-Polyfill of URLSearchParams in core-js
-The URL interface.
-Google Developers: Easy URL manipulation with URLSearchParams

See also on MDN

Constructors

URLSearchParams()

public URLSearchParams()

URLSearchParams(Union153)

The URLSearchParams() constructor creates and returns a
new URLSearchParams object.

public URLSearchParams(Union153 init = default)

Parameters

init Union153

Remarks

Properties

this[int]

public string this[int i] { get; set; }

Parameters

i int

Property Value

string

Size

The size read-only property of the URLSearchParams interface indicates the total number of search parameter entries.

[Value("size")]
public ulong Size { get; }

Property Value

ulong

A number indicating the total number of search parameter entries in the URLSearchParams object.

Remarks

Methods

Append(string, string)

The append() method of the URLSearchParams
interface appends a specified key/value pair as a new search parameter.

[Value("append")]
public GlobalObject.Undefined Append(string name, string value)

Parameters

name string
value string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

As shown in the example below, if the same key is appended multiple times it will
appear in the parameter string multiple times for each value.

-URL
-Google Developers: Easy URL manipulation with URLSearchParams

See also on MDN

Delete(string, string)

The delete() method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.

[Value("delete")]
public GlobalObject.Undefined Delete(string name, string value = null)

Parameters

name string
value string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

A parameter name and optional value are used to match parameters.
If only a parameter name is specified, then all search parameters that match the name are deleted, along with their associated values.
If both a parameter name and value are specified, then all search parameters that match both the parameter name and value are deleted.

-Polyfill of URLSearchParams in core-js

See also on MDN

Get(string)

The get() method of the URLSearchParams
interface returns the first value associated to the given search parameter.

[Value("get")]
public string? Get(string name)

Parameters

name string

Returns

string

A string if the given search parameter is found; otherwise,
null.

Remarks

GetAll(string)

The getAll() method of the URLSearchParams
interface returns all the values associated with a given search parameter as an array.

[Value("getAll")]
public List<string> GetAll(string name)

Parameters

name string

Returns

List<string>

An array of strings, which may be empty if no values for the given parameter are found.

Remarks

Has(string, string)

The has() method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.

[Value("has")]
public bool Has(string name, string value = null)

Parameters

name string
value string

Returns

bool

A boolean value.

Remarks

A parameter name and optional value are used to match parameters.
If only a parameter name is specified, then the method will return true if any parameters in the query string match the name, and false otherwise.
If both a parameter name and value are specified, then the method will return true if a parameter matches both the name and value.

-Polyfill of URLSearchParams in core-js

See also on MDN

Set(string, string)

The set() method of the URLSearchParams
interface sets the value associated with a given search parameter to the given value.
If there were several matching values, this method deletes the others. If the search
parameter doesn&apos;t exist, this method creates it.

[Value("set")]
public GlobalObject.Undefined Set(string name, string value)

Parameters

name string
value string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Sort()

The URLSearchParams.sort() method sorts all key/value
pairs contained in this object in place and returns undefined. Key/value pairs are sorted by the values of the UTF-16 of the keys. This method uses a stable sorting
algorithm (i.e., the relative order between key/value pairs with equal keys will be
preserved).

[Value("sort")]
public GlobalObject.Undefined Sort()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks