QueryString
Represents a query string associated with a URL and provides methods to manage its parameters.
継承元: Equatable<QueryString>
実装: IEnumerable<KeyValuePair<string, string>>, IEnumerable
プロパティ
public object Item { get; set; }
value = queryString.Item
queryString.Item = value
Gets or sets the value of the specified query field.
- queryField
- The query field name.
戻り値: The value of the query field.
public string Raw { get; }
value = queryString.Raw
Gets the raw query string composed from the key-value pairs.
メソッド
public QueryString Append(string name, object value)
result = queryString.Append(name, value)
Appends a new query parameter to the query string. If the same key is appended multiple times, each value becomes a separate query parameter (e.g., ids=1&ids=2&ids=3).
- name
- The name of the query parameter.
- value
- The value of the query parameter.
戻り値: The current instance with the new parameter added.
public QueryString Clear()
result = queryString.Clear()
Clears all the query parameters.
戻り値: The current instance with all query parameters removed.
public override QueryString Clone()
result = queryString.Clone()
Creates a new instance of QueryString that is a copy of the current instance.
戻り値: A new instance of QueryString with the same query parameters and URL.
public bool Contains(string queryField)
result = queryString.Contains(queryField)
Checks whether the specified query field exists.
- queryField
- The query string field name.
戻り値: True if the query field exists; otherwise, false.
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
result = queryString.GetEnumerator()
Returns an enumerator that iterates through the key-value pairs of the query string.
戻り値: An enumerator for the query parameters.
public override int GetHashCode()
result = queryString.GetHashCode()
Serves as the default hash function.
戻り値: A hash code for the current object.
public T GetValue<T>(string queryField)
result = queryString.GetValue(queryField)
Retrieves the value of a query parameter converted to the specified type.
- queryField
- The query field name.
戻り値: The converted value of the query parameter.
protected override bool OnEquals(QueryString other)
result = queryString.OnEquals(other)
Determines whether the specified QueryString is equal to the current instance.
- other
- The QueryString to compare with the current instance.
戻り値: True if the query strings are equal (ignoring case); otherwise, false.
public QueryString Remove(string name)
result = queryString.Remove(name)
Removes a query parameter from the query string.
- name
- The name of the query parameter to remove.
戻り値: The current instance with the parameter removed if it existed.
public override string ToString()
result = queryString.ToString()
Returns the compiled query string.
戻り値: The query string as a string.
public bool TryGetValue<T>(string queryField, T value)
result = queryString.TryGetValue(queryField, value)
Attempts to retrieve the value of a query parameter converted to the specified type.
- queryField
- The query field name.
- value
- When this method returns, contains the converted value if the query parameter exists; otherwise, the default value of T.
戻り値: True if the query parameter exists and conversion was successful; otherwise, false.
public T TryGetValue<T>(string queryField)
result = queryString.TryGetValue(queryField)
Attempts to retrieve the value of a query parameter converted to the specified type. Returns the default value of T if the query parameter is not found.
- queryField
- The query field name.
戻り値: The converted value if found; otherwise, the default value of T.
public T TryGetValue<T>(string queryField, T defaultValue)
result = queryString.TryGetValue(queryField, defaultValue)
Attempts to retrieve the value of a query parameter converted to the specified type. Returns a specified default value if the query parameter is not found.
- queryField
- The query field name.
- defaultValue
- The default value to return if query parameter is not found.
戻り値: The converted value if found; otherwise, the specified default value.