I have a webservice which I have edited, before it worked without a problem. however right now im getting this error: cannot be serialized because it does not have a parameterless constructor I have posted my class below.
public class Class
{
public class AnsweredQ
{
public string Question { get; set; }
public string Answer { get; set; }
public AnsweredQ(string _Question, string _Answer)
{
Question = _Question;
Answer = _Answer;
}
}
public class UnAnsweredQ
{
public string Question { get; set; }
public string[] Options { get; set; }
public UnAnsweredQ(string _Question, string[] _Options)
{
Question = _Question;
Options = _Options;
}
}
public class Trial
{
public string User { get; set; }
public DateTime TrialDate { get; set; }
public bool Expired { get; set; }
public Trial (string _User, DateTime _TrialDate, bool _Expired)
{
User = _User;
TrialDate = _TrialDate;
Expired = _Expired;
}
}
}
if you can solve this please explain what i did wrong 🙂
To be able to serialize / deserialize a class, the serializer requires a parameterless constructor. So, you need to add the parameterless constructors to your classes, i.e.: