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>>, IEnumerableConstructors
| Name | Description |
|---|---|
| QueryStringParameterCollection() | Initializes a new instance of the QueryStringParameterCollection class. |
QueryStringParameterCollection()
QueryStringParameterCollection.csInitializes a new instance of the QueryStringParameterCollection class.
public QueryStringParameterCollection()Properties
| Name | Description |
|---|---|
| Count | Gets the number of parameters in the collection. |
| IsEmpty | Gets a value indicating whether the collection is empty. |
Indexers
| Name | Description |
|---|---|
| this[string] | Gets or sets the parameter value with the specified name. |
this[string]
QueryStringParameterCollection.csGets or sets the parameter value with the specified name.
public StringValues this[string name] { get; set; }Methods
| Name | Description |
|---|---|
| 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.csAppends 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
namestring- The name of the parameter.
valuesStringValues- The values to append.
Append(string, string?)
QueryStringParameterCollection.csRemoves all parameters from the collection.
public void Clear()Get(string)
QueryStringParameterCollection.csGets the value associated with the specified parameter name.
public StringValues Get(string name)Parameters
namestring- The name of the parameter to get.
Returns
StringValues The value associated with the specified name, or StringValues.Empty if not found.
GetEnumerator()
QueryStringParameterCollection.csReturns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<string, StringValues>> GetEnumerator()Returns
IEnumerator<KeyValuePair<string, StringValues>> An enumerator for the collection.
Remove(string)
QueryStringParameterCollection.csSet(string, StringValues)
QueryStringParameterCollection.csSets 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
namestring- The name of the parameter.
valuesStringValues- The values to set.