开发者

How to Serialize collection

I have class with property of type ISet. I want to serialize that class but don't know how to do with ISet.

[Se开发者_JAVA技巧rializable]    
class Question: ISerializable
{
  private int id;
  public int Id
  {
    get{return id;}
    set{id = value;}
  }

  private ISet answerChoice;
  public ISet AnswerChoices
  {
   get{return answerChoices;}
   set { answerChoices = value; }
  }

  public Question(SerializationInfo info, StreamingContext context)
  {
       id = info.GetInt32("id");
       answerChoices = //how to deserialize this collection
  }

  void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
  {
       info.AddValue("id", id);
       info.AddValue("ac", answerChoices);
  }
}

Do anyone try to make the same? Please, help me.


How about:

info.GetValue("ac",...);

And why do you implement you own serialization if you do not add any additional value?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜