I have 3 classes:

```
class O
{
}

class A : O
{
}

class B : A
{
}

```

When I call my code:

```
List<O> myList = new List<O>();
myList.Add(new A());
myList.Add(new B());

foreach (O obj in myList)
{
    if (obj is A)
    {
         // do something
    }
    else if (obj is B)
    {
         //do something
    }
}

```

However I realized that `if (obj is A)` will be evaluated to be `true` even when my `obj` is of `class B`. Is there a way to write the statement such that it evaluates to true if and only if `obj` is of `class B`?