/// <summary> /// Gets the query value by a specific key. /// </summary> /// <param name="key">The key.</param> /// <param name="separator">An optional string to use as a separator is included in the returned string only if it has more than one value.</param> /// <returns>The query value.</returns> public string GetValue(string key, string separator = null) { var arr = ListExtensions.GetValues(this, key).ToList(); if (arr.Count == 0) { return(null); } return(string.Join(separator ?? ValueSeparator ?? string.Empty, arr)); }
/// <summary> /// Gets the query value by a specific key. /// </summary> /// <param name="key">The key.</param> /// <param name="ignoreEmpty">true if ignore empty; otherwise, false.</param> /// <returns>The query value. The last one for multiple values..</returns> public string GetLastValue(string key, bool ignoreEmpty = false) { var col = ListExtensions.GetValues(this, key); return(ignoreEmpty ? col.LastOrDefault(item => !string.IsNullOrWhiteSpace(item)) : col.LastOrDefault()); }