title: C# Error 4 Cannot implicitly convert type. Generic Interfaces
body: <p>For anyone who is experienced with C# this issue should be easy to fix. I want to make it so that subjects can have a list of courses. There are both tutor and students in this application. Thus, I created a generic Subject that defines the properties that both Tutor_Subject and Student_Subject implement. However I am getting a weird casting error. </p>
  
  <pre><code>public interface Subject&lt;TCourse&gt; where TCourse : Course
  {
    int SubjectId { get; set; }
    string Name { get; set; }
  
    ICollection&lt;TCourse&gt; Courses { get; set; }
  }
  
  public partial class Student_Subject :Subject&lt;Student_Course&gt;
  {
  }
  
  public partial class Tutor_Subject :Subject &lt;Tutor_Course&gt;
  {
  }
  
  public interface Course
  {
      int CourseId { get; set; }
      string Name { get; set; }
  }
  
  public partial class Student_Course :Course
  {
  }
  
  public partial class Tutor_Course :Course
  {
  }
  </code></pre>
  
  <p>Here is the issue</p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'Tutor_Subject' to 'Course'. An explicit conversion exists (are you missing a cast?)</p>
  </blockquote>
  
  <pre><code>Subject&lt;Course&gt; subject;
  
  if(type ==1)
  {
      subject = new Student_Subject();  // Error 
      courseList = subjectInfo["courses"].ToObject&lt;IList&lt;Student_Course&gt;&gt;();
  }
  else
  {
      subject = new Tutor_Subject();  // Error
      courseList = subjectInfo["courses"].ToObject&lt;IList&lt;Tutor_Course&gt;&gt;();
  }
  
  subject.Name = subjectName;
  subject.Courses = courseList.ToList();
  </code></pre>