title: Comparing types
body: <p>I have a Generic method where I need to compare the generic type with another type.</p>
  
  <p>The following code always throws the exception:</p>
  
  <pre><code>if (!(_vertexType.DataType is T))
     throw new Exception();
  </code></pre>
  
  <p>But this doesn't:</p>
  
  <pre><code>if(_vertexType.DataType != default(T).GetType())
     throw new Exception();
  </code></pre>
  
  <p>Why is this? Is there something about the <em>is</em> operator I don't understand?</p>
  
  <p>If it helps, the _vertexType.DataType function looks like this:</p>
  
  <pre><code>Type DataType
  {
     get { return default(myType).GetType(); }
  }
  </code></pre>
  
  <p>Tips on how to do it properly would be great too.</p>