我遇到了一个问题,其中以下 ToJson() 方法返回一个只有“{}”的字符串
public class GenericRequest
{
public enum SupportedCommands
{
REGISTER, LOGIN, LOGOUT
}
private SupportedCommands command;
private String authentication;
private String password;
private String email;
public GenericRequest(SupportedCommands comm, string aut, string pass, string mail)
{
command = comm;
authentication = aut;
password = pass;
email = mail;
}
virtual public string ToJson()
{
return JsonConvert.SerializeObject(this);
}
}
知道为什么序列化命令不序列化类的成员吗?