c# .net 将List序列化
程序员文章站
2022-04-14 14:13:42
...
/// <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()); }
上一篇: Python切片知识解析
下一篇: C#.net常用常混淆的知识点