Home  >  Article  >  Backend Development  >  c# .net serializes List

c# .net serializes List

巴扎黑
巴扎黑Original
2016-12-19 17:13:572125browse

/// <summary>
        /// 序列化List
        /// </summary>
        /// <param name="al"></param>
        /// <returns>string</returns>
        public string SerializeArrayList(ArrayList al)
        {
            Type[] extra = new Type[1];
            extra[0] = typeof(LocalNetInfo);
           // extra[0] = typeof(string);
            XmlSerializer xs = new XmlSerializer(typeof(ArrayList), extra);
            MemoryStream ms = new MemoryStream();
            XmlTextWriter tw = new XmlTextWriter(ms, Encoding.Default);
            xs.Serialize(tw, al);
            tw.Close();
            return Encoding.Default.GetString(ms.ToArray());
        }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn