I am a beginner in XML and I would like to save Students with their fields into XML. But I dont know how to save "type" as object. Here is my code:
class Student
{
private int id;
private string name;
private string surname;
public Type type;
public Student(int id, string name, string surname, Type type)
{
this.id = id;
this.name = name;
this.surname = surname;
this.type = type;
}
}
class Type
{
private string ID;
private string name;
public Odbor(string ID, string name)
{
this.ID = ID;
this.name= name;
}
}
class Program
{
static void Main(string[] args)
{
Type type1 = new Type("IRT","info");
Type type2 = new Type("MATH","mathematic");
List<Student> Students = new List<Student>();
Students.Add(new Student(10,"Jon","Snow", type1));
Students.Add(new Student(11,"Ned","Stark", type2));
//Save Students to XML
}
}
Thanks for help.