# OfType

`ShouldBeOfType` is the inverse of `ShouldNotBeOfType`.

## ShouldBeOfType

```cs
var theSimpsonsDog = new Cat { Name = "Santas little helper" };
theSimpsonsDog.ShouldBeOfType<Dog>();
```

[snippet source](https://github.com/shouldly/shouldly/blob/master/src/DocumentationExamples/CodeExamples/ShouldBeOfTypeExamples.ShouldBeOfType.codeSample.approved.cs#L1-L2) | [anchor](#snippet-ShouldBeOfTypeExamples.ShouldBeOfType.codeSample.approved.cs)

**Exception**

```
theSimpsonsDog
    should be of type
Simpsons.Dog
    but was
Simpsons.Cat
```

## ShouldNotBeOfType

```cs
var theSimpsonsDog = new Cat { Name = "Santas little helper" };
theSimpsonsDog.ShouldNotBeOfType<Cat>();
```

[snippet source](https://github.com/shouldly/shouldly/blob/master/src/DocumentationExamples/CodeExamples/ShouldBeOfTypeExamples.ShouldNotBeOfType.codeSample.approved.cs#L1-L2) | [anchor](#snippet-ShouldBeOfTypeExamples.ShouldNotBeOfType.codeSample.approved.cs)

**Exception**

```
theSimpsonsDog
    should not be of type
Simpsons.Cat
    but was
Santas little helper
```
