I have this structure:
public class StudentNew
{
public int StudentId { get; set; }
...
}
public class RootObjectNew
{
public List<StudentNew> StudentsNew { get; set; }
public int test { get; set; }
}
and I want to set properties to StudentsNew.
RootObjectNew RootObjectNewObject = new RootObjectNew();
RootObject obj = JsonConvert.DeserializeObject<RootObject>(Out);
int i = -1;
foreach (var stu in obj.Students)
{
i++;
RootObjectNewObject.StudentsNew[i].StudentId = stu.Id;
RootObjectNewObject.test = 123;
}
but get error:
2018-03-03T09:18:55.628 [Info] Compilation succeeded.
2018-03-03T09:18:56.971 [Info] C#************************
2018-03-03T09:18:57.386 [Error] Exception while executing function: Functions.fGetStudentBySkudId. Microsoft.Azure.WebJobs.Script: One or
more errors occurred. f-fGetStudentBySkudId__-2136340708: Object
reference not set to an instance of an object.
If I comment
RootObjectNewObject.StudentsNew[i].StudentId = stu.Id;
I get status = 200 what am I doing wrong???