title: Why does "int[] is uint[] == true" in C#
body: <p>Can somebody clarify the C# <code>is</code> keyword please. In particular these 2 questions:</p>
  
  <p>Q1) line 5; Why does this return true?</p>
  
  <p>Q2) line 7; Why no cast exception?</p>
  
  <pre><code>public void Test()
  {
      object intArray = new int[] { -100, -200 };            
  
      if (intArray is uint[]) //why does this return true?
      {
          uint[] uintArray = (uint[])intArray; //why no class cast exception?
  
          for (int x = 0; x &lt; uintArray.Length; x++)
          {
              Console.Out.WriteLine(uintArray[x]);
          }
      }
  }
  </code></pre>
  
  <p>MSDN's description does not clarify the situation. It states that <code>is</code> will return true if either of these conditions are met. (http://msdn.microsoft.com/en-us/library/scekt9xw(VS.71).aspx>MDSN Article)</p>
  
  <pre>
  expression is not null.
  expression can be cast to type.
  </pre>
  
  <p>I don't believe that you can do a valid cast of int[] into uint[]. Because:</p>
  
  <p>A) This code does not compile:</p>
  
  <pre><code>int[] signed = new int[] { -100 };
  uint[] unsigned = (uint[])signed; 
  </code></pre>
  
  <p>B) Doing the cast in the debugger gives an error:</p>
  
  <pre><code>(uint[])signed
  "Cannot convert type 'int[]' to 'uint[]'"
  </code></pre>
  
  <p>Sure enough, if line 3 was int[] instead of object then it would never compile. Which brings me to a final question related to Q2.</p>
  
  <p>Q3) Why does C# raise a cast/conversion error in the debugger and compiler but not at runtime?</p>