如何在MemoryStream中使用C#保存聊天记录 [英] how to save chat history in MemoryStream use C#

查看:278
本文介绍了如何在MemoryStream中使用C#保存聊天记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#在MemoryStream中保存聊天记录,请帮帮我.谢谢

how to save chat history in MemoryStream use C#,please help me.thanks

推荐答案

您好,如果您将消息存储在集合中,那将是一个简单的东西.
假设您有List< chatmsg> _msgs,因此将集合存储在MemoryStream中将由下一个代码段执行:

Hi , if you are storing your messages in collection, it would be an easy stuff.
Lets say that you have List<chatmsg> _msgs, so storing your collection in MemoryStream will be performed by next code snippet:

using(MemoryStream ms=new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(ms, _msgs);
            writeStream.Close();
}



希望这会有所帮助.



Hope , this will help.


这篇关于如何在MemoryStream中使用C#保存聊天记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆