Dictionary<string, string[]> temp = new Dictionary<string, string[]>();          temp只是一个临时变量,经过运算赋值后,下次又赋不同的值,如何保存前面的结果呢?

解决方案 »

  1.   

    viewstate保存
    Dictionary泛型类派生并实现IXmlSerializable
    public class ComponentsProperties : Dictionary<string, Dictionary<string,string>>, System.Xml.Serialization.IXmlSerializable
    {
        #region IXmlSerializable Members
        public System.Xml.Schema.XmlSchema GetSchema()
        {
            throw new NotImplementedException();
        }    public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader.IsEmptyElement)
                return;        reader.Read();
            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                string key = reader.Name;
                this[key] = new Dictionary<string, string>();
                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                        this[key][reader.Name] = reader.ReadElementString();
                }
                reader.Read();
            }
        }    public void WriteXml(System.Xml.XmlWriter writer)
        {
            foreach (string key in this.Keys)
            {
                writer.WriteStartElement(key);
                foreach (string key1 in this[key].Keys)
                    writer.WriteElementString(key1, this[key][key1]);
                writer.WriteEndElement();
            }
        }
        #endregion
    }
      

  2.   

    Dictionary<string, string[]>第二个类型是string[]数组呀。
      

  3.   

    List<Dictionary<string, string[]>> tempListadd进去不就可以了
      

  4.   

    你是说string[]吧?每次都Clone一下才行。
    lz先理解一下引用类型和值类型吧!
      

  5.   

    List<T>定义属性
    Dictionary<string, string[]>>实现保持
    序列化保存