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

Set() public method

public Set ( String name, String value ) : void
name String
value String
return void
        public virtual void Set(String name, String value)
        {
            if (IsReadOnly)
                throw new NotSupportedException(SR.CollectionReadOnly);

            InvalidateCachedArrays();

            ArrayList values = new ArrayList(1);
            values.Add(value);
            BaseSet(name, values);
        }

Same methods

NameValueCollection::Set ( string name, string value ) : void

Usage Example

Example #1
0
        static public System.Collections.Specialized.NameValueCollection ReadIni(string sFileName)
        {
            System.Collections.Specialized.NameValueCollection coll = null;
            string sTxt = cc.Util.readAll(sFileName);

            if (sTxt != null)
            {
                coll = new System.Collections.Specialized.NameValueCollection();
                string[] lines = sTxt.Replace("\n", "").Split('\r');
                for (int i = 0; i < lines.Length; i++)
                {
                    string line = lines[i].Trim();
                    if (line.Equals("") || line.StartsWith("#") || line.StartsWith(";"))
                    {
                        continue;
                    }

                    int npos;
                    npos = line.IndexOf("=");
                    if (npos > 0)
                    {
                        string skey = line.Substring(0, npos);
                        if (coll.Get(skey) != null)
                        {
                            coll.Set(skey, coll.Get(skey) + "\r\n" + line.Substring(npos + 1));
                        }
                        else
                        {
                            coll.Set(skey, line.Substring(npos + 1));
                        }
                    }
                }
            }
            return(coll);
        }
All Usage Examples Of System.Collections.Specialized.NameValueCollection::Set