笔记:xml序列化


        /// <summary>
        /// xml序列化
        /// </summary>
        /// <param name="root"></param>
        /// <param name="dic"></param>
        /// <returns></returns>

        private static XElement XmlSerialize(string root,Dictionary<string, object> dic)
        {
           
            XElement el = new XElement(root,
            dic.Select(kv => new XElement(kv.Key, kv.Value)));
            return el;
        }

        private static List<XElement> XmlSerialize(Dictionary<string, object> dic)
        {
            List<XElement> list = new List<XElement>();
            foreach (var item in dic)
            {
                list.Add(new XElement(item.Key, item.Value));
            }
            return list;
        }
View Code

相关文章:

  • 2022-02-06
  • 2021-10-09
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-12-06
  • 2021-07-19
猜你喜欢
  • 2021-06-26
  • 2021-12-18
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2022-01-27
  • 2021-10-29
相关资源
相似解决方案