I have the following class:
public class Student
{
public int studentNumber;
public string testWeek;
public string topics;
}
I do some stuff to it, serialize it and save it in a file. It looks likes this:
[
{
"studentNumber": 1,
"testWeek": "1",
"topics": "5 & 8"
},
{
"studentNumber": 2,
"testWeek": "1",
"topics": "5 & 8"
},
{
"studentNumber": 3,
"testWeek": "1",
"topics": "5 & 8"
},
{
"studentNumber": 4,
"testWeek": "1",
"topics": "5 & 8"
},
{
"studentNumber": 5,
"testWeek": "1",
"topics": "5 & 8"
}
]
Later I want to deserialize it so I can work on it again. I have this code
Student[] arr = new Student[numberOfStudentsInClass];
arr = JsonConvert.DeserializeObject<Student>(File.ReadAllText(_selectedClass))
Where _selectedClass is string containing the file name. But I am getting an error
Cannot convert WindowsFormApplicationsForm1.Form.Student to WindowsFormApplicationsForm1.Form.Student[]