我有 ISet 类型的属性的类。我想序列化该类,但不知道如何处理 ISet。
[Serializable]
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);
}
}
有没有人尝试做同样的事情?请帮我。