title: C# generic collections: using them in public properties without making the class generic
body: <p>Non generic collections are often presented as obsolete, a sort of a legacy of the first implementation of the C# collection framework.<br />
  If that was the case, I should have a way to solve the following, very common problem with a generic solution.</p>
  <p>This is a simple class that writes on the Console the items of the collection it receives.</p>
  <pre><code>public class ValuesWriter
  {
      public IList Values { get; set; }
  
      public void Write()
      {
          foreach(object o in Values)
          {
              Console.WriteLine(o.ToString());
          }
      }
  
  }
  </code></pre>
  <p>The usage is this:</p>
  <pre><code>List&lt;string&gt; stringValues = new List&lt;string&gt;() { &quot;first&quot;, &quot;second&quot;, &quot;third&quot; };
  ValuesWriter w1 = new ValuesWriter() { Values = stringValues };
  w1.Write();
  
  List&lt;int&gt; intValues = new List&lt;int&gt;() { 1, 2, 3 };
  ValuesWriter w2 = new ValuesWriter() { Values = intValues };
  w2.Write();
  </code></pre>
  <h3>Question</h3>
  <p>Is there another efficient way to handle a generic collection as a public property without turning my class into a generic class itself?</p>