I have a list of properties, all are public and have getter and setter. But not all of them are serialized, few are missing. Can anyone tell me what could be the possible reason ?
//My class with public properties
public class student
{
public int id {get; set;};
public string fname {get; set;};
public string lname {get; set;};
}
//class where i include the above student class
[XmlInclude(typeof(student))]
public class event
{}
//Xml Serializer
XmlSerializer xmlSerializer = new XmlSerializer(event.GetType());
FileStream fileStream = File.Open(
filePathWithName,
FileMode.OpenOrCreate,
FileAccess.Write,
FileShare.ReadWrite);
xmlSerializer.Serialize(fileStream, event);
var stringwriter = new System.IO.StringWriter();
var serializer = new XmlSerializer(event.GetType());
serializer.Serialize(stringwriter, event);
//xml file
<?xml version="1.0"?>
<Student>
<id>1</id>
<fname>abc</fname>
</Student>
Now here the property lname is missing