title: Can I create a bag of objects that will hold different kinds o generic objects?
body: <p>This one was hard to come up with a good title, so I gave my best shot at it.</p>
  
  <p>Here is the problem:</p>
  
  <pre><code>Dictionary&lt;string,ILayer&gt; _layers = new Dictionary&lt;string,ILayer&gt;();
  _layers.Add("IntLayer",new Layer&lt;int&gt;());
  _layers.Add("GuidLayer",new Layer&lt;Guid&gt;());
  Guid value = _layers["GuidLayer"].GetValue(int x, int y);
  </code></pre>
  
  <p>The classes:</p>
  
  <pre><code>public class Layer&lt;T&gt; : ILayer
  {
      public T[,] Matrix { get; set; }
  
      public T GetValue(int x, int y)
      {
          return Matrix[x, y];
      }
  }   
  
  public interface ILayer
  {
      //T GetValue(int x, int y);
  }
  </code></pre>
  
  <p>The idea is to be able to store different kinds of layers, and avoid the explicit casting. Although one would know the type when trying to get a value so it could be casted safely, but if I ever want to apply something across the layer it would make things a little more complicated there for a "generic" method would be better.</p>
  
  <p>Is it possible to create this scenario? Should I be going a completely different way about this problem?</p>
  
  <p>Thanks for any help</p>