C# question about inheritance

class C inherit from class B that inherit from class gameObject.

I have an array of gameObject. When i test :

if (gameObj is B)

Visual C# underline it saying the given expression is never of the given type (B).

At runtime i know one of the object has been created as a C, but it never match my if condition. Why?

How can Visual C# know that it will not work?

In Unity 3.0 GameObject is a sealed class, so you cannot derive from it. Maybe this is your underlying problem.

You might want to look at this post and GetComponent to do what you are trying to do.