public static string _GetQueryStringFirst(this IQueryCollection d, string key, string defaultStr = "", StringComparison comparison = StringComparison.OrdinalIgnoreCase, bool autoTrim = true) { if (key._IsEmpty()) { throw new ArgumentNullException(nameof(key)); } if (d == null) { return(defaultStr); } var matchList = d.Where(x => x.Key._IsSameTrim(key, comparison)); if (matchList.Any() == false) { return(defaultStr); } StringValues values = matchList.First().Value; string?ret = values.Where(x => (autoTrim ? x._IsFilled() : x != null)).FirstOrDefault(); if (ret._IsEmpty()) { return(defaultStr); } if (autoTrim) { ret = ret._NonNullTrim(); } return(ret); }