当我尝试如下声明序列化程序时,我收到此错误。它返回错误,我不明白这意味着什么。
var serializer = MsgPack.Serialization.MessagePackSerializer.Create<data>();
以下是类定义。
using System;
using System.Collections.Generic;
using System.Text;
namespace TickDataDefinition
{
class data
{
private enum type { trade, quote }
private long time;
private double bid1;
private double ask1;
private double bidsize;
private double asksize;
private double price;
private uint size;
public data()
{
}
public data(long t, double b, double a, double bs, double ask)
{
time = t;
bid1 = b;
ask1 = a;
bidsize = bs;
asksize = ask;
}
public data(long t, double p, uint s)
{
time = t;
price = p;
size = s;
}
}
}
答案 0 :(得分:1)
该类的所有元素都是私有的,而不是构造函数(无论如何都无法序列化,如果是这样的话就没有意义)。公开一些实际可访问的元素并序列化。