title: C# Templated Struct: Cannot implicitly convert
body: <p>Evening all, my problem is with the following:</p>
  
  <pre><code>public struct vector2D&lt;T1&gt;
  {
      public T1 m_w;
      public T1 m_h;
  
      // Irrelevant stuff removed (constructor, other overloader's)
  
      public static bool operator !=(vector2D&lt;T1&gt; src, T1 dest)
      {
          return (((dynamic)src.m_w != (dynamic)dest) || ((dynamic)src.m_h != (dynamic)dest));
      }
  
      public static bool operator ==(vector2D&lt;T1&gt; src, T1 dest)
      {
          return (((dynamic)src.m_w != (dynamic)dest) || ((dynamic)src.m_h != (dynamic)dest));
      }
  
      public static bool operator !=(vector2D&lt;T1&gt; src, vector2D&lt;T1&gt; dest)
      {
          return (((dynamic)src.m_w != (dynamic)dest.m_w) || ((dynamic)src.m_h != (dynamic)dest.m_h));
      }
  
      public static bool operator ==(vector2D&lt;T1&gt; src, vector2D&lt;T1&gt; dest)
      {
          return Equals(src, dest);
      }
  }
  </code></pre>
  
  <p>Now the error's I get is:</p>
  
  <pre><code>Error   1   Operator '!=' cannot be applied to operands of type 'vector2D&lt;int&gt;' and 'vector2D&lt;uint&gt;'
  Error   2   Cannot implicitly convert type 'vector2D&lt;uint&gt;' to 'vector2D&lt;int&gt;'
  </code></pre>
  
  <p>Now I know the compiler doesn't know how to "cast" with the following code fragment: </p>
  
  <pre><code>vector2D&lt;uint&gt;[] Something = new vector2D&lt;uint&gt;[2]; // Pretend it has values...
  Dictonary&lt;uint, vector2D&lt;int&gt;&gt; AnotherThing = new Dictonary&lt;uint, vector2D&lt;int&gt;&gt;(); // Pretend it has values...
  
  if (AnotherThing[0] != Something[0] ) { ... }
  
  AnotherThing[0] = Something[0];
  </code></pre>
  
  <p>I've tried several thing and simply they either give me more errors and don't work or don't work. So my question is how would I go about doing the "casting"?</p>
  
  <p><em>Also might be good to mention, I usually program in C++ so C# has surprised me a few times. Also sorry in advance if the above code gives you nightmares.</em></p>