QueryStringParameterCollection Class

Represents a collection of query string parameters that preserves insertion order and allows duplicate keys with multiple values.

public sealed class QueryStringParameterCollection : IEnumerable<KeyValuePair<string, StringValues>>, IEnumerable
Implements

Constructors

NameDescription
QueryStringParameterCollection()Initializes a new instance of the QueryStringParameterCollection class.

QueryStringParameterCollection()

QueryStringParameterCollection.cs

Initializes a new instance of the QueryStringParameterCollection class.

public QueryStringParameterCollection()

Properties

NameDescription
CountGets the number of parameters in the collection.
IsEmptyGets a value indicating whether the collection is empty.

Gets the number of parameters in the collection.

public int Count { get; }

Property value

int

Gets a value indicating whether the collection is empty.

public bool IsEmpty { get; }

Property value

bool

Indexers

NameDescription
this[string]Gets or sets the parameter value with the specified name.

Gets or sets the parameter value with the specified name.

public StringValues this[string name] { get; set; }

Parameters

name string
The name of the parameter.

Property value

StringValues

Methods

NameDescription
Append(string, StringValues)Appends the specified values to an existing parameter or adds a new parameter if it doesn't exist.
Append(string, string?)Appends the specified value to an existing parameter or adds a new parameter if it doesn't exist.
Clear()Removes all parameters from the collection.
Get(string)Gets the value associated with the specified parameter name.
GetEnumerator()Returns an enumerator that iterates through the collection.
Remove(string)Removes the parameter with the specified name from the collection.
Set(string, StringValues)Sets the value of a parameter, replacing any existing values, or adds the parameter if it doesn't exist.
System.Collections.IEnumerable.GetEnumerator()

Append overloads

Append(string, StringValues)

QueryStringParameterCollection.cs

Appends the specified values to an existing parameter or adds a new parameter if it doesn't exist.

public void Append(string name, StringValues values)
Parameters
name string
The name of the parameter.
values StringValues
The values to append.

Append(string, string?)

QueryStringParameterCollection.cs

Appends the specified value to an existing parameter or adds a new parameter if it doesn't exist.

public void Append(string name, string? value)
Parameters
name string
The name of the parameter.
value string?
The value to append.

Removes all parameters from the collection.

public void Clear()

Gets the value associated with the specified parameter name.

public StringValues Get(string name)

Parameters

name string
The name of the parameter to get.

Returns

StringValues The value associated with the specified name, or StringValues.Empty if not found.

Returns an enumerator that iterates through the collection.

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

Returns

IEnumerator<KeyValuePair<string, StringValues>> An enumerator for the collection.

Removes the parameter with the specified name from the collection.

public bool Remove(string name)

Parameters

name string
The name of the parameter to remove.

Returns

bool true if the parameter was found and removed; otherwise, false.

Set(string, StringValues)

QueryStringParameterCollection.cs

Sets the value of a parameter, replacing any existing values, or adds the parameter if it doesn't exist.

public void Set(string name, StringValues values)

Parameters

name string
The name of the parameter.
values StringValues
The values to set.

System.Collections.IEnumerable.GetEnumerator()

QueryStringParameterCollection.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.