title: Generics appear not to be the same in class and method
body: <p>I asked this question before but it was put on hold because the problem was a 'simple' conversion problem. For me this isn't. This is the first time I try to work with generics.</p>
  
  <p>I have a <code>Class</code> like the code here without any errors:</p>
  
  <pre><code>internal class GridBox&lt;T&gt; : BoxBase // where T : new()
  {
      public GridBox(Grid grid, GridBoxView view, MessageBoxIcon icon, string caption, ObservableCollection&lt;T&gt; dataSource, MessageBoxButton button)
          : base(grid, icon, caption, button)
      {
          View = view;
          DataSource = dataSource;
      }
  
      public GridBoxView View { get; set; }
      public ObservableCollection&lt;T&gt; DataSource { get; set; }
  }
  </code></pre>
  
  <p>Next I use this <code>Class</code> to pass a lot of data between different <code>Classes</code> starting with the code below:</p>
  
  <pre><code>public static T Show&lt;T&gt;(DependencyObject sender, MessageBoxIcon icon, string caption, ObservableCollection&lt;T&gt; dataSource, MessageBoxButton button) where T : IComparable&lt;T&gt;, new()
  {
      Window window = Window.GetWindow(sender);
      Grid grid = Extensions.FindChild&lt;Grid&gt;(window);
      GridBoxView gridBox = new GridBoxView();
  
      return gridBox.Show&lt;T&gt;(new GridBox&lt;T&gt;(grid, gridBox, icon, caption, dataSource, button));
  }
  </code></pre>
  
  <p>This code can be compiled without any errors. Am I right if I say that <code>where T : IComparable&lt;T&gt;</code> is needed to use <code>T</code> inside the <code>Method</code> and the extra <code>, new()</code> is needed to use it at <code>new GridBox&lt;T&gt;</code>? Again, first time experimenting with generics.</p>
  
  <p>The above code that calls <code>Show&lt;T&gt;</code> is below here:</p>
  
  <pre><code>internal class GridBoxViewModel&lt;T&gt; : BoxBaseViewModel // where T : new()
  {
      public T Show&lt;T&gt;(GridBox&lt;T&gt; gridBox)
      {
          // Set content item
          DataSource = gridBox.DataSource;
  
          // Set visual items and block the excecution code 
          AddView(gridBox.Grid, gridBox.View, gridBox.Icon, gridBox.Caption, gridBox.Button);
  
          // Return value
          return SelectedItem;
      }
  
      public ObservableCollection&lt;T&gt; DataSource { get; set; }
      public T SelectedItem { get; set; }
  }
  </code></pre>
  
  <p>Here the problems start. <code>DataSource = gridBox.DataSource</code> gives an error that it can't convert <code>System.Collections.ObjectModel.ObservableCollection&lt;T&gt;</code> to <code>System.Collections.ObjectModel.ObservableCollection&lt;T&gt;</code> which appears to me as the same. Both are referring to the same <code>Class Library</code> <code>[C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll]</code>.</p>
  
  <p>The second problem is with <code>return SelectedItem;</code>. The error here is pretty much the same but a bit different tho. It can't convert <code>'T'</code> to <code>'T [Controls\ViewModels\GridBoxViewModel.cs(6)]'</code>.</p>
  
  <p>The obvious reason for me is that the <code>T</code> at <code>internal class GridBoxViewModel&lt;T&gt; : BoxBaseViewModel</code> isn't the same <code>T</code> as at <code>public T Show&lt;T&gt;(GridBox&lt;T&gt; gridBox)</code>. Is this actually the cause and if so, how should I handle this problem and fix it?</p>