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
Constructors
URLSearchParams()
public URLSearchParams()
URLSearchParams(Union153)
The URLSearchParams() constructor creates and returns a
new URLSearchParams object.
public URLSearchParams(Union153 init = default)
Parameters
initUnion153
Remarks
Properties
this[int]
public string this[int i] { get; set; }
Parameters
iint
Property Value
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
Returns
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
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
Returns
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.
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
namestring
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
namestring
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
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.
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't exist, this method creates it.
[Value("set")]
public GlobalObject.Undefined Set(string name, string value)
Parameters
Returns
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()