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

Add() public method

public Add ( NameValueCollection c ) : void
c NameValueCollection
return void
        public void Add(NameValueCollection c)
        {
            if (c == null)
            {
                throw new ArgumentNullException(nameof(c));
            }

            InvalidateCachedArrays();

            int n = c.Count;

            for (int i = 0; i < n; i++)
            {
                String key = c.GetKey(i);
                String[] values = c.GetValues(i);

                if (values != null)
                {
                    for (int j = 0; j < values.Length; j++)
                        Add(key, values[j]);
                }
                else
                {
                    Add(key, null);
                }
            }
        }

Same methods

NameValueCollection::Add ( String name, String value ) : void
NameValueCollection::Add ( System c ) : void
NameValueCollection::Add ( string name, string value ) : void

Usage Example

        public override string GetVideoUrl(VideoInfo video)
        {
            CookieContainer newCc = new CookieContainer();
            foreach (Cookie c in cc.GetCookies(new Uri(@"https://www.filmon.com/")))
            {
                newCc.Add(c);
            }

            NameValueCollection headers = new NameValueCollection();
            headers.Add("Accept", "*/*");
            headers.Add("User-Agent", userAgent);
            headers.Add("X-Requested-With", "XMLHttpRequest");
            string webdata = GetWebData(video.VideoUrl, (string)video.Other, newCc, headers: headers);

            JToken jt = JObject.Parse(webdata) as JToken;
            JArray streams = jt.Value<JArray>("streams");
            video.PlaybackOptions = new Dictionary<string, string>();
            foreach (JToken stream in streams)
            {
                string serverUrl = stream.Value<string>("url");

                RtmpUrl res = new RtmpUrl(serverUrl);
                res.Live = true;
                res.PlayPath = stream.Value<string>("name");

                int p = serverUrl.IndexOf("live/?id");
                res.App = serverUrl.Substring(p);
                video.PlaybackOptions.Add(stream.Value<string>("quality"), res.ToString());
            }

            return video.PlaybackOptions.First().Value;
        }
All Usage Examples Of System.Collections.Specialized.NameValueCollection::Add