c# add values to an array or object code example
Example 1: c# add object to array
Array.Resize(ref objArray, objArray.Length + 1);
objArray[objArray.Length - 1] = new Someobject();
Example 2: add items to a class array
class Student
{
IList<Subject> subjects = new List<Subject>();
}
class Subject
{
string Name;
string referenceBook;
}
//Now you can say:
someStudent.subjects.Add(new Subject());