我正在尝试使用C#中的二进制序列化来序列化一个类对象。我试过了,在我见过的所有例子中,我所能找到的所有序列化数据总是放到一个文件中。
在我的例子中,我必须将序列化数据存储在SQL中。下面是我创建的方法的一个示例。
//Serializing the List
public void Serialize(Employees emps, String filename)
{
//Create the stream to add object into it.
System.IO.Stream ms = File.OpenWrite(filename);
//Format the object as Binary
BinaryFormatter formatter = new BinaryFormatter();
//It serialize the employee object
formatter.Serialize(ms, emps);
ms.Flush();
ms.Close();
ms.Dispose();
}
如何在字符串变量中直接获取序列化数据?我不想使用文件。
请帮帮忙。
转载请注明出处:http://www.fortunesungroup.com/article/20230331/1997624.html