System.Collections.Specialized.NameValueCollection.HasKeys C# (CSharp) Method

HasKeys() public method

public HasKeys ( ) : bool
return bool
        public bool HasKeys()
        {
            return InternalHasKeys();
        }

Usage Example

        public static string ToQueryString(NameValueCollection collection, bool startWithQuestionMark = true)
        {
            if (collection == null || !collection.HasKeys())
                return String.Empty;

            var sb = new StringBuilder();
            if (startWithQuestionMark)
                sb.Append("?");

            var j = 0;
            var keys = collection.Keys;
            foreach (string key in keys)
            {
                var i = 0;
                var values = collection.GetValues(key);
                foreach (var value in values)
                {
                    sb.Append(key)
                        .Append("=")
                        .Append(value);

                    if (++i < values.Length)
                        sb.Append("&");
                }
                if (++j < keys.Count)
                    sb.Append("&");
            }
            return sb.ToString();
        }
All Usage Examples Of System.Collections.Specialized.NameValueCollection::HasKeys