1

当我尝试如下声明序列化程序时出现此错误。它返回错误,我不明白它的含义。

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;
        }

    }
}
4

1 回答 1

1

该类的所有元素都是私有的,而不是构造函数(无论如何都不能序列化,如果是这样就没有意义)。公开一些实际可访问的元素并序列化。

于 2014-03-11T14:45:23.640 回答