> For the complete documentation index, see [llms.txt](https://docs.shouldly.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shouldly.org/documentation/equality/oftype.md).

# OfType

`ShouldBeOfType` is the inverse of `ShouldNotBeOfType`.

## ShouldBeOfType

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

[<sup>snippet source</sup>](https://github.com/shouldly/shouldly/tree/master/src/DocumentationExamples/CodeExamples/ShouldBeOfTypeExamples.ShouldBeOfType.codeSample.approved.cs#L1-L2) <sup>|</sup> [<sup>anchor</sup>](#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>();
```

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

**Exception**

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