title: How to use generic delegates in C#
body: <p><strong>I have these classes:</strong></p>
  
  <pre><code>public interface IPerson
  {
      string Name { get; set; }
  }
  
  public class Person : IPerson
  {
      public string Name { get; set; }
  }
  
  public interface IRoom
  {
      List&lt;Furniture&gt; Furnitures { get; set; }
      List&lt;Person&gt; People { get; set; }
  }
  
  public class Room : IRoom
  {
      public List&lt;Furniture&gt; Furnitures { get; set; }
      public List&lt;Person&gt; People { get; set; }
  }
  
  public enum Furniture
  {
      Table,
      Chair
  }
  </code></pre>
  
  <hr>
  
  <p><strong>And I have this extension method:</strong></p>
  
  <pre><code>public static void Assign&lt;T&gt;(this IRoom sender, Func&lt;IRoom,ICollection&lt;T&gt;&gt; property, T value)
  {
      // How do I actually add a Chair to the List&lt;Furniture&gt;?
  
  }
  </code></pre>
  
  <hr>
  
  <p><strong>And I want to use it like this:</strong></p>
  
  <pre><code>var room = new Room();
  room.Assign(x =&gt; x.Furnitures, Furniture.Chair);
  room.Assign(x =&gt; x.People, new Person() { Name = "Joe" });
  </code></pre>
  
  <p>But I have no idea how to add <code>T</code> to <code>ICollection&lt;T&gt;</code>.</p>
  
  <p>Trying to learn generics and delegates. I know <code>room.Furnitures.Add(Furniture.Chair)</code> works better :)</p>