namespace TestOOP
{
using System;
using System.Collections.Generic;
using System.Linq;
internal sealed class Student
{
private string name;
}
internal sealed class Course
{
private ICollection<Student> students;
public ICollection<Student> Students
{
get { return this.students; }
set { this.students = Students; }
}
}
class Program
{
static void Main()
{
var course = new Course();
course.Students.Add(new Student());
Console.WriteLine(course.Students.Count());
}
}
}
Thats my code. When running it I get object not set to an instance of an object at the line where I try to add student to a course. I need help explaining how to use interfaces as fields.