0

我正在尝试实现一个简单的构造,我首先清除 NameValueCollection 并向其写入新值。但是目前我不能,因为它是只读的。有没有办法让它不只读或四处走走?我的代码:

NameValueCollection DataDictionary = ConfigurationManager.GetSection("dataDictionary") as NameValueCollection;
            DataDictionary.Clear();
            for (int i = 0; i < tableLayoutPanel2.RowCount; i++)
            {
                var T = tableLayoutPanel2.GetControlFromPosition(1, i);
                var T2 = tableLayoutPanel2.GetControlFromPosition(3, i);
                string key = T.Text;
                string value = T2.Text;
                DataDictionary.Add(key, value);
            }
4

1 回答 1

0

将其复制到一个NameValueCollection的:

var writableCollection = new NameValueCollection(DataDictionary);
writableCollection.Add(...);
于 2014-12-11T16:52:58.753 回答