要将类标记为可序列化
- 在类定义前添加
[Serializable]
属性。
[Serializable]
public class WorkorderAddData
{
public int id;
public Response response;
[Serializable]
public class Response
{
public int id;
[Serializable]
public class ImgJsonList
{
public int type;
}
public object Clone()
{
using (var stream = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(stream, this);
stream.Seek(0, SeekOrigin.Begin);
return formatter.Deserialize(stream);
}
}
}
public object Clone()
{
using (var stream = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(stream, this);
stream.Seek(0, SeekOrigin.Begin);
return formatter.Deserialize(stream);
}
}
}
标签:序列化,stream,Clone,Serializable,Unity,var,new,formatter,public
From: https://blog.csdn.net/teemoboy/article/details/141220488